Android ListView总是空的

Android ListView总是空的,android,android-layout,Android,Android Layout,嘿 我的ListView在我的代码中始终为空。我不知道为什么。setAdapter方法中出现错误。请帮助 代码: ListView lv=(ListView)findViewById(R.id.lv_sp); ArrayList=新的ArrayList(); EntryParse ep=newentryparse(LVEntries.this,getIntent().getExtras().getString(“JSON”); list=ep.getList(); //列表=新的ArrayLis

我的
ListView
在我的代码中始终为空。我不知道为什么。setAdapter方法中出现错误。请帮助

代码:

ListView lv=(ListView)findViewById(R.id.lv_sp);
ArrayList=新的ArrayList();
EntryParse ep=newentryparse(LVEntries.this,getIntent().getExtras().getString(“JSON”);
list=ep.getList();
//列表=新的ArrayList();
Log.e(“SP”,String.valueOf(list.size());
ca=新的CustomAdapter(this,R.layout.customlistitem,list);
低压设置适配器(ca);
ca.notifyDataSetChanged();
布局:

<LinearLayout
  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/lv_sp" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" ></ListView>
</LinearLayout>


我没有看到调用
setContentView
。必须先设置布局,然后检索视图。

Null,还是空?如果为空,您应该在lv.setAdapterId处获得NullPointerException您忘记调用setContentView了吗?此外,您可能希望扩展
ListActivity
,为列表和空视图提供id
android:id/list
android:id/empty
,然后使用
setListAdapter
设置适配器。
<LinearLayout
  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/lv_sp" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" ></ListView>
</LinearLayout>