[英]Two line - single item inside a list view - how to?
How do i do it? 我该怎么做? i've searched and looked and still haven't found anything usefull for me. 我已经搜索并查找,但仍然找不到对我有用的东西。
I currently have 2 arraylist. 我目前有2个arraylist。 first one includes Strings of calculations i got from a previous activity. 第一个包括我从上一个活动获得的计算字符串。 second one includes Doubles of results of the above mentioned calculations i got from a previous acitivty. 第二个是我从先前的活动中获得的上述计算结果的两倍。
I've saved both Arraylists in SQLLITE database. 我已经将两个Arraylists保存在SQLLITE数据库中。
The best i got so far is: 到目前为止,我得到的最好成绩是:
inside onCreate: 里面的onCreate:
SimpleAdapter adapter = new SimpleAdapter(this, list,
R.layout.custom_row_view,
new String[] { "operationName", "operationValue" }, new
int[] { R.id.text1,R.id.text2 });
populateList();
setListAdapter(adapter);
inside a function - populateList(); 在函数内部-populateList(); : :
static final ArrayList<HashMap<String, Double>> list = new ArrayList<HashMap<String, Double>>();
private void populateList() {
HashMap<String, Double> temp = new HashMap<String, Double>();
for (int i = 1; i <= 20; i++) {
temp.put(operationNames.get(i), operationValues.get(i));
}
list.add(temp);
}
EDIT: The custom_row_view .xml: 编辑:custom_row_view .xml:
<?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"
android:orientation="vertical" >
<TextView
android:id="@+id/tv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#CBC300"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#3200A3"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
What am i missing here? 我在这里想念什么? it keeps crashing when entering this specific listactivity. 输入此特定的listactivity时,它总是崩溃。
Any help will be really appreciated. 任何帮助将不胜感激。
in your code you try to get third element from list of 2 elements! 在您的代码中,您尝试从2个元素的列表中获取第三个元素! You can set some default values to this list or show only 2 items. 您可以为此列表设置一些默认值,或仅显示2个项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.