android - 我可以在Dialog中添加可扩展列表吗?

时间:2013-06-14 05:18:07

标签: android expandablelistview

我想在对话框中显示可扩展列表。有可能这样做吗?如果是,那怎么样?请帮帮我。

4 个答案:

答案 0 :(得分:3)

是的,这是可能的创建自定义对话框并在其布局中添加可扩展列表

自定义对话框的好教程是here

答案 1 :(得分:1)

应该尝试这个:

Dialog d = new Dialog(this);
TextView test = new TextView(this);
test.setText("test");
d.setContentView(test);
d.show();

应该使用您定义的更复杂的视图:

LayoutInflater l = this.getLayoutInflater();
View v = l.inflate(R.id.yourView, false);
d.setContentView(v);
d.show();

答案 2 :(得分:0)

Is it possible to create an expandable list AlertDialog?

此链接对您的问题也有帮助,它会在对话框中显示消耗列表视图 为了降低复杂性,您可以使用消耗性列表视图创建活动,并将该活动显示为对话框,这将使其更加简单

Android Activity as a dialog

这有助于将您的活动替换为对话框。

答案 3 :(得分:-1)

有很多方法可以实现这一点。我总是喜欢自定义对话框的最简单方法是

将您的UI和相应的Java编码构建为通常的Activity。然后在清单中,将其主题指定为对话框。

<activity android:theme="@android:style/Theme.Dialog" 
android:name="ClassName"></activity>
相关问题