первый ответ здесь ... Простое отображение данных из базы данных SQlite или здесь Пользовательские просмотры списка, 3 строки на элемент?
ну ... не былоплохо, но это было все равно что убить комара из дробовика
, для этого вам не нужно создавать собственный адаптер
, просто используйте SimpleCursorAdapter
dbAdaptor = new DBAdaptor(this);
//!!!!remeber scroresCursor MUST have "_id" column
scoresCursor = dbAdaptor.getScores();
listView.setAdapter(new SimpleCursorAdapter(this,
//this is itemrow.xml
R.layout.itemrow,
scoresCursor ,
//"from" this is array of columns
new String[]{DBAdaptor.KEY_PLAYER1_SCORE, DBAdaptor.KEY_PLAYER2_SCORE, DBAdaptor.KEY_PLAYER3_SCORE, DBAdaptor.KEY_PLAYER4_SCORE},
//"to" next goes ids in itemrow.xml, values from "from" columns are mapped to "to" Views
new int[] {R.id.tvwPlayer1score, R.id.tvwPlayer2score, R.id.tvwPlayer3score, R.id.tvwPlayer4score }));
далее: вывозможность отображать эти данные в виде списка в активности (не в диалоге)?
РЕДАКТИРОВАТЬ:
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialogus);
ListView lv = (ListView)dialog.getWindow().findViewById(R.id.listView1);
Cursor c = managedQuery(
Uri.parse("content://selvin.ListSyncSample/List"),
new String[] { "_id", "Name",
"Description", "CreatedDate" }, null,
null, "Name");
lv.setAdapter(new SimpleCursorAdapter(this, R.layout.listrow, cursor, new String[] { "Name",
"Description", "CreatedDate" }, new int[] {
R.id.tName, R.id.tDescription, R.id.tCreatedDate }));
dialog.setTitle("Custom Dialog");
dialog.show();
itemrow.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:padding="6dip">
<ImageView android:id="@+id/icon" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginRight="6dip"
android:src="@drawable/icon" android:layout_centerVertical="true" />
<TextView android:id="@+id/tName" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_toRightOf="@id/icon"
android:layout_alignParentRight="true" android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:singleLine="true" android:ellipsize="marquee" />
<TextView android:id="@+id/tDescription" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_toRightOf="@id/icon"
android:layout_alignParentRight="true" android:layout_below="@id/tName" />
<TextView android:id="@+id/tCreatedDate" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_toRightOf="@id/icon"
android:layout_alignParentRight="true" android:layout_below="@id/tDescription"
android:singleLine="true" android:ellipsize="marquee" />
</RelativeLayout>
custom_dialogus.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">
<ListView android:id="@+id/listView1" android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
вместо курсора c = managedQuery ... используйте курсор