What I'm trying to do is as follows:
The speech recognizer returns some words he has recognized, and I want to show them in a textField, now I read that it must be done with a list so I wrote this:
In the oncreate:
setContentView(R.layout.activity_main);
mList = (ListView) findViewById(R.id.list);
where mList is a private ListView var.
This is the result function then:
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, matches);
mList.setAdapter(arrayAdapter);
In my activity_main.xml I have added this:
ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
Somehow the program isn't showing my list.
I followed this tutorial: http://developer.android.com/guide/topics/ui/layout/gridview.html
Am I missing something?
android:layout_height="0dip" seems wrong. It should probably be "wrap_content" instead.
I had some double list in my xml with the same name.. :-) Works fine after change 0dip to wrap content. Thanks everybody!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.