我在片段中有一个按钮,当我单击时,我需要打开一个包含列表视图项的对话框,但我无法打开包含列表项的对话框
final ListView lv = (ListView) view.findViewById(R.id.mylist);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.list_view);
dialog.setTitle("Custom Dialog");
ArrayAdapter<String> selectedAdapter = new ArrayAdapter<String>(getActivity(), R.layout.list_view,R.id.text, event);
selectedAdapter.setNotifyOnChange(true);
lv.setAdapter(selectedAdapter);
dialog.show();
}
});
我的列表视图
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<ListView
android:id="@+id/mylist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#b5b5b5"
android:dividerHeight="5dp" />
</LinearLayout>
任何帮助表示赞赏。