I am using ListActivity to display simple text with SimpleCursorAdapter to get the texts from my database. I have tried to debug the problem and found that the cursor is successfully fetching the result but the text is not displayed in the ListView.
Following is the ListActivity code I am using.
public class MyListActivity extends ListActivity{ Cursor myCursor; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); myCursor = getData(); startManagingCursor(myCursor); ListAdapter myAdapter = new SimpleCursorAdapter(this, R.layout.display_details, myCursor, new String[]{MyDbHelper.ID_FIELD, MyDbHelper.NAME_FIELD}, new int[]{R.id.row_id, R.id.row_name}); setListAdapter(myAdapter); } private Cursor getData() { return MyDBHelper.getRoutes(); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); routesCursor.close(); } } and following is my xml file for each row in ListView
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/row_id" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/row_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/row_id" android:layout_toRightOf="@+id/row_id" android:textAppearance="?android:attr/textAppearanceLarge" /> </RelativeLayout> and my layout for ListActivity is as following
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent"> </ListView> </RelativeLayout> Please provide me the solution. Thanks in advance.