[英]setting up icons for a list
I have an app in android that in some activity it displays using a item list the content from a column from the DB.我在 android 中有一个应用程序,它在某些活动中使用项目列表显示来自数据库的列中的内容。
this is the way I'm doing it:这就是我这样做的方式:
lv = (ListView) findViewById(R.id.list);
Cursor cursor = db.getAllData();
startManagingCursor(cursor);
adapter = new SimpleCursorAdapter(this, R.layout.listitem, cursor,
new String[] { db.KEY_USER }, new int[] { R.id.txt1 });
lv.setAdapter(adapter);
I'm using an adapter to connect the text view and the content of the table.我正在使用适配器来连接文本视图和表格的内容。
Here is how my Xml looks like"这是我的 Xml 的样子”
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/txt1"
android:textSize="20dip"
android:padding="8dip" />
My question is:我的问题是:
How could I setup icons and colour for every list item that comes connected with my data from DB?如何为与数据库中的数据相关的每个列表项设置图标和颜色?
You might want to consider using android.app.ListActivity .您可能要考虑使用android.app.ListActivity 。 With a list activity you can provide an xml layout to create advanced visuals for your items.
通过列表活动,您可以提供 xml 布局来为您的项目创建高级视觉效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.