मुझे सूची दृश्य और संदेश दोनों के साथ संवाद बनाने की आवश्यकता है, हालांकि http://code.google.com/p/android/issues/detail?id=10948 के अनुसार यह मानक AlertDialog के साथ संभव नहीं है। तो मैंने पाठ और सूचीदृश्य के साथ कस्टम दृश्य बनाने का निर्णय लिया है, और इसे संवाद में संलग्न किया है।सूची दृश्य और संदेश के साथ संवाद
हालांकि, मेरी सूची दृश्य खाली खींचा गया है।
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Hello, title!");
LayoutInflater factory = LayoutInflater.from(this);
View content = factory.inflate(R.layout.dialog, null);
ListView lv = (ListView) content.findViewById(R.id.list);
lv.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_single_choice, ITEMS));
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
builder.setView(content).setPositiveButton("OK", this).setNegativeButton("Cancel", this);
AlertDialog alert = builder.create();
alert.show();
इसके अलावा मेरे पास है:
किसी भी मदद की बहुत सराहना की है:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, text!" />
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/list"
></ListView>
</LinearLayout>
यहाँ परिणाम है:
final String[] ITEMS = new String[] { "a", "b", "c" };
और यहाँ संवाद लेआउट है यहाँ जावा कोड है । धन्यवाद!