我正在尝试从listview
实现填充SQLite
,但是android突然listview
没有出现在屏幕上。我的代码出了什么问题。
这是我的ListView
布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/white">
<ListView
android:id="@+id/listview_AllPost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="1dp"
android:longClickable="true"></ListView>
</LinearLayout>
这是我的活动代码
listView = (ListView) findViewById(R.id.listview_AllPost);
populateList();
private void populateList() {
descArray.clear();
List<All_Post> allDesc = dbhelper.getAllDescriptions();
for (All_Post all_Post : allDesc)
{
String strInspectorname = all_Post.getStringInspectorname();
Log.e("strInspectorname "," = " + strInspectorname);
descArray.add(all_Post);
}
if (adapter == null)
{
adapter = new AllPostAdapter(this, R.layout.allpostlist, descArray);
listView.setAdapter(adapter);
}
else if (adapter != null) {
adapter.notifyDataSetChanged();
adapter = new AllPostAdapter(this, R.layout.allpostlist, descArray);
listView.setAdapter(adapter);
}
}