I have created a ListActivity inside a tabhost, and this tab is supposed to show all records from a sql table. When I click the tab however, it shows the right amount of rows (separation lines) but there's no data/text anything else to be seen. So basically I get an empty list, and I've checked the database file, the data is there!
My table only has the columns _id and name.
This is the code I'm using:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Cursor c;
ShowAdapter sa = new ShowAdapter(this);
sa.open();
c = sa.getSubscribedShows();
String[] from = new String[] { "name" };
int to[] = new int[] { R.id.text1 };
SimpleCursorAdapter shows = new SimpleCursorAdapter(this, R.layout.show_list, c, from, to);
setListAdapter(shows);
sa.close();
}
And my other method simply returns the cursor:
public Cursor getSubscribedShows(){
Cursor c = db.query(true, "shows", null,开发者_JAVA百科 null, null, null, null, "name", null);
c.moveToFirst();
return c;
}
And my XML is:
<?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="fill_parent"
android:padding="10dp"
android:textSize="16sp"
android:id="@+id/text1" >
</TextView>
Any ideas what I'm doing wrong?
Change the layout_height
propery to:
android:layout_height="wrap_content"
and see if that fixes it
精彩评论