I am changing the question at the root, how can I display the data in a list with a view so that each field is separate? I deduce in this way, but the information is all stored in one line of the View.
public class RequestHistoryListActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.history_database_request); DatabaseOpenHelper dbhelper = new DatabaseOpenHelper(getBaseContext()); SQLiteDatabase sqliteDB = dbhelper.getReadableDatabase(); String[] from = { HistoryColumns.REQUEST, BaseColumns._ID }; final Cursor c = sqliteDB.query(History.TABLE_NAME, from, null, null, null, null, null); int[] to = new int[] { R.id.text1 }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.list, c, from, to); ListView lv = (ListView) findViewById(R.id.listView1); lv.setAdapter(adapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { // c.moveToPosition(pos); int rowId = c.getInt(c.getColumnIndexOrThrow(BaseColumns._ID)); // Uri outURI = Uri.parse(data.toString() + rowId); /* * Intent outData = new Intent(); History oneRow = new History(); * oneRow.setId(c.getLong(c.getColumnIndexOrThrow(BaseColumns._ID))); * oneRow.setRequest(c.getString(c.getColumnIndexOrThrow(HistoryColumns.REQUEST))); * setResult(Activity.RESULT_OK, outData); finish(); */ Log.v(MainActivity.TAG, rowId); } }); } }
history_database_request.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="wrap_content" > </ListView> </LinearLayout>
and then what we deduce
lisr.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="wrap_content"> <LinearLayout android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="wrap_content"> <TextView android:id="@+id/text1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is text1" android:textSize="25dip" /> </LinearLayout> </LinearLayout>