i want to fill ** **Listview** ** Widget in android with Records from table of sqllite database and show the content of table's field using button and imageview widget.
如果有任何带有 sqlite 数据库和图像的示例可用,它将帮助所有开发人员开发他的应用程序
i want to fill ** **Listview** ** Widget in android with Records from table of sqllite database and show the content of table's field using button and imageview widget.
如果有任何带有 sqlite 数据库和图像的示例可用,它将帮助所有开发人员开发他的应用程序
如果要自定义列表视图。看看这个链接:
http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
您必须创建一个 xml 布局文件,其中包含一个内衬布局中的 listview。还有一个用于设计列表视图的 lisviewstyle xml 文件。
希望这会有所帮助。干杯!!!
此编码将对您有所帮助。
在 main.xml
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#302217"
android:cacheColorHint="#333333"
android:divider="#999966"
android:dividerHeight="2dp"
android:fastScrollEnabled="true" >
和 listStyle 用于设计列表视图
<TextView
android:id="@+id/txtView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp" >
</TextView>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</Button>
创建从数据库中检索数据的方法:-
public Cursor createBlacklist()
{
Cursor cur=null;
try
{
sqliteDb=dncDb.getReadableDatabase();
cur=sqliteDb.query("tableName", new String[]{"_id","fieldOfDatabase"}, null, null, null, null, null);
}
catch(Exception exce)
{
exce.printStackTrace();
}
return cur;
}
获取列表视图:-
Cursor cursor = createBlacklist();
startManagingCursor(cursor);
String[] from = { "fieldOfDatabase" };
int[] to = { R.id.txtView};
SimpleCursorAdapter simpleListAdapter = new SimpleCursorAdapter(
CreateBlackList.this, R.layout.liststyle, cursor, from, to);
setListAdapter(simpleListAdapter);
ListView list = getListView();