我有一个简单的数据库,其中包含<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">this is mt4</h4>
</div>
<div class="modal-body">
this is the text: <%= modal['text1'] %>
</div>
</div>
...
列和_id
列。
尝试打印listView,但我的代码没有显示任何内容(我也没有错误,在LOG中我也有正确的值)。
感谢您的帮助。
EventActivity.java
createdOn
list_activity.xml
[...]
private void getEvent(){
db = new DBManager(this);
Cursor cursor = db.query();
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.list_activity,
cursor,
new String[] { "createdOn" },
new int[] { R.id.singleDate });
ListView listView = (ListView) findViewById(R.id.listDate1);
listView.setAdapter(adapter);
while (cursor.moveToNext()) {
Log.d(LOGTAG, cursor.getLong(0) + " " + cursor.getString(1));
// here I have all my entries in log
}
list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/listDate1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
</ListView>
</RelativeLayout>
答案 0 :(得分:1)
您的错误在于创建适配器
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.list_row, // that's the layout to inflate for each row
cursor,
new String[] { "createdOn" }, // those are the cursor columns
new int[] { R.id.singleDate }); // those are the layout views
// to match to the cursor columns