Wednesday, July 13, 2011

[android-developers] alert dialog with refreshable listview

hej,
I want to create a simple AlertDialog with ListView. the list contains
all entries in my local db, so in onCreateDialog I created alert
builder and added items to it with onItemClick callback.

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.recorded_list_titile)
.setItems(new CharSequence[]{}, new
DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface
dialogInterface, int index)
{
//actions
}
});
return builder.create();

but then I realized that list will change any time user adds entry to
db. so I added onPrepareDialog. and now Im lost. I could use adapter
from dialog listView but this adapter operates only on list of names.

my entry from db is mapped to class Entry {id, name}. in order to find
out which id user selected I have to created custom adapter -
CustomAdapter<Entry>. but adapter expect definition of row layout
which I really dont need because AlertDialog should already create
standard one.

then I probably end writing my own ViewHolder for adapter and
onItemClick callback.

I think this should be a lot simpler!!!

thanks for any help!

--
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