我想做一个自定义对话框与列表视图这将包含复选框和textviews,我只是找不到合理的教程做到这一点,任何帮助或提示将不胜感激。自定义ListView里面的对话框在android
0
A
回答
5
private void showPopUp()
{
final AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
helpBuilder.setTitle("");
LayoutInflater inflater = getLayoutInflater();
final View PopupLayout = inflater.inflate(R.layout.yourxml, null);
helpBuilder.setView(PopupLayout);
final AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();
jobList = (ListView)PopupLayout.findViewById(R.id.list);
mylist = new ArrayList<HashMap<String, String>>();
for(int i=0;i<arraylist.size();i++)
{
map = new HashMap<String, String>();
map.put("name", arraylist.get(i));
mylist.add(map);
}
sd = new SimpleAdapter(activity.this,mylist,R.layout.jobslist,
new String[]{"name"},new int[]{R.id.jobText});
jobList.setAdapter(sd);
}
joblist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lin01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:padding="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/jobText"
android:layout_width="0dp"
android:text="@string/jobtype"
android:layout_weight="1"
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:textColor="#000"
android:layout_height="50dp"/>
<CheckBox
android:id="@+id/chk"
android:layout_width="wrap_content"
android:text=""
android:gravity="center_vertical|right"
android:layout_height="wrap_content"/>
</LinearLayout>
,无论你想显示与列表视图的警告对话框中,你可以调用这个函数showPopUp();
。请注意,会有数组列表,您可以添加项目以显示列表中的项目
2
ListView myList = new ListView(Activity.this);
myList.setAdapter(adapter);
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);
builder.setView(myList);
Dialog d = builder.create();
d.show();
您可以指定文本视图和复选框以及适配器中的其他内容。
1
这听起来像你要找的是ListView的多种选择模式。不知道这句话是相当困难得到一个很好的例子,但here's another SO question with answers that might help you out.
(在对话框这样做本质上是相同的过程中所选择的答案的例子。)
相关问题
- 1. Android - ListView里面的对话框
- 2. android自定义对话框
- 3. Android自定义对话框
- 4. Android自定义对话框
- 5. 自定义对话框Android
- 6. ListView与自定义对话框
- 7. 使用ListView自定义对话框
- 8. 在android中的自定义对话框?
- 9. 在自定义对话框的Android
- 10. 使用ListView在自定义对话框中(android)
- 11. 取代facebook对话框中的自定义对话框在android
- 12. Android:自定义提醒对话框出现在DEFULT对话框
- 13. Android的自定义对话框的EditText
- 14. Android的对话框自定义样式
- 15. Android自定义形状的对话框
- 16. 与Android的自定义对话框
- 17. android asynctask中的自定义对话框
- 18. Android的自定义微调对话框
- 19. 自定义对话框成为Android的
- 20. Android自定义对话框的Datepicker
- 21. 的Android自定义对话框(DialogFragment)
- 22. Android自定义对话框的位置
- 23. Android - 从另一个自定义对话框显示自定义对话框
- 24. Android自定义列表对话框
- 25. android自定义对话框错误
- 26. Android自定义对话框高度
- 27. Android自定义对话框不工作
- 28. Android自定义进度对话框
- 29. 自定义对话框不显示 - Android
- 30. Android自定义对话框图像