is it possible to create listview inside dialog?

前端 未结 6 1341
天涯浪人
天涯浪人 2020-11-30 23:17

i have created a custom dialog class

public class NewPost extends Dialog
{
// functionality

}

now my requirement is to create listview ins

6条回答
  •  执念已碎
    2020-11-30 23:31

    The simplest possible way:

        ListView listView = new ListView(this);
        listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, new String[] {"item 1", "item 2", "item 3"}));
        Dialog dialog = new Dialog(this);
        dialog.setContentView(listView);
        dialog.show();
    

提交回复
热议问题