views:

73

answers:

1

I have a simple grid with rows of items and columns of options on each item. Of course I can manually link OnClick actions to cell items through specific resource IDs:

views.setOnClickPendingIntent(R.id.row1column1, launchA); views.setOnClickPendingIntent(R.id.row1column2, launchB); // ... views.setOnClickPendingIntent(R.id.row2column1, launchC); // ...

What I'd prefer to to is use a ListView or a GridView and an Adapter. Is there a way to get cell id's from one of those? I was hoping that ListView setOnItemClickListener() would call me with the view id of a view within row 'position':

onItemClick(AdapterView parent, View view, int position, long id) { ... }

but no go. Maybe a different approach?

Thanks.

Update:

I started with this:

contactsView.setAdapter(new ContactAdapter(this.getApplicationContext(), R.layout.contact, contacts));
contactsLV.setOnItemClickListener(new OnItemClickListener() { ... });

I'd assumed that I couldn't go into my Adapter and set child view OnClickListeners. Bad assumption. When I went back at this I gave it a try:

Button x  = (Button)newView.findViewById(R.id.contact_x);
Button y = (Button)newView.findViewById(R.id.contact_y);
x.setOnClickListener(new OnClickListener() { ... });
y.setOnClickListener(new OnClickListener() { ... });
...

Voila!

A: 

I developed a multicolumn grid with sortable columns, using table layout structure.

Maybe it can help you:

http://www.cabotcode.org

Bye

Paolo