It is necessary to transfer data to the dialogue, I made a separate layout, on which ListView and in which the whole data array is supposed to be written, but it is not written, the code is below:
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); LayoutInflater factory = LayoutInflater.from(this); View content = factory.inflate(R.layout.dialog, null); ListView lv = (ListView) content.findViewById(R.id.list); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Hello, title!"); AlertDialog alert = builder.create(); alert.show(); lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, matches));
It gives only a window in which hello title is written, is it wrong? Tell me, pliz.
The issue is resolved!
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); listDialog = new Dialog(this); listDialog.setTitle("Select Item"); LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = li.inflate(R.layout.dialog, null, false); listDialog.setContentView(v); listDialog.setCancelable(true); // there are a lot of settings, for dialog, check them all out! ListView list1 = (ListView) listDialog.findViewById(R.id.list); // list1.setOnItemClickListener(this); list1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, matches)); listDialog.show();