[英]ListView android shows nothing
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: 语音识别器返回他已经识别的一些单词,我想在textField中显示它们,现在我读到它必须用一个列表来完成,所以我这样写:
In the oncreate: 在oncreate中:
setContentView(R.layout.activity_main);
mList = (ListView) findViewById(R.id.list);
where mList is a private ListView var. 其中,mList是私有ListView变量。
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: 在我的activity_main.xml中,添加了以下内容:
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 我遵循了本教程: http : //developer.android.com/guide/topics/ui/layout/gridview.html
Am I missing something? 我想念什么吗?
android:layout_height="0dip" seems wrong. android:layout_height =“ 0dip”似乎错误。 It should probably be "wrap_content" instead.
它可能应该是“ wrap_content”。
I had some double list in my xml with the same name.. :-) Works fine after change 0dip to wrap content. 我在xml中有一个具有相同名称的重复列表。.:-)在更改0dip来包装内容后,效果很好。 Thanks everybody!
谢谢大家!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.