views:

197

answers:

2

dear friends,

i have created a custom dialog class

public class NewPost extends Dialog
{
// functionality

}

now my requirement is to create listview inside it. i know we can create textboxes,buttons,dropdown list inside it.

but in order to create list view we should inherit our class from listActivity class

what you suggest is it possible or not if yes then how to achieve this using any interface or what?

any help would be appriciated.

+1  A: 

You don't really have to extend listActivity in order to use listviews.

Extending listActivity will give you some functionality for free, such as getListView() (if I recall the method name correctly), but that can just as well be done manually with findViewById() just as any other view.

David Hedlund
+2  A: 

Yes.

You can always use a ListView inside a Dialog. And you definitely don't necessarily need ListActivity to create ListView.

Code may be something like this:

Dialog dlg = new Dialog(context);
LayoutInflater li = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = li.inflate(R.layout.my_layout, null, false);
dlg.setContentView(v);
dlg.show();

my_layout.xml:

<ScrollView xmlns:android="blah"
   android:id="xid"
   android:layout_height="h"
   android:layout_width="w">

  <ListView blah blah blah attributes
  />

 </ScrollView>
MasterGaurav