Monday, June 7, 2010

[android-developers] Focus problem in GridView inside Dialog

H there,

I have a little problem with selecting items that are inside GridView
that is displayed inside a dialog.

What I want to achieve is a dialog window that shows a grid of images
that user can select (click on them) and some action is executed. I
figured I'd just create a GridView backed by ListAdapter and set that
on the Dialog. But that causes some problems. Once you scroll the list
of images, they become unselectable. Using trackball brings the
selection back to the items and they become clickable again, until you
scroll the list. This really gives me a headache.

Below is the code I use to create my dialog:

GridView myView = new GridView(MyActivity.this);
myView.setNumColumns(2);
myView.setAdapter(myImages.getListAdapter());
myView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Log.i(TAG, "onItemClick: ");
}
});

Dialog myDialog = new Dialog(MyActivity.this);
myDialog.setTitle("My Cool Images");
myDialog.setContentView(myView);

return myDialog;

Am I missing something here? The sample code from ApiDemos is not much
different, except that it does not involve Dialogs, so I'm thinking it
might be something related to Dialog stuff.

Cheers,
Piotr

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment