在列表视图中创建水平列表视图时出现问题..
myAdapter adapter = new myAdapter(thisActivity, kategoriList,
R.layout.list_item,
new String[] { "nama","thumbnail"}, new int[] {
R.id.name, R.id.thumb_kategori});
setListAdapter(adapter);
HorizontalListView listview = (HorizontalListView) findViewById(R.id.listview2);
listview.setAdapter(mAdapter);
这是布局:我正在使用 Dev-SmartLib 中的 Horitontal Listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Name Label -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/thumb_kategori"
android:layout_width="40dp"
android:layout_height="40dp" />
<TextView
android:id="@+id/name"
android:layout_width="238dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.devsmart.android.ui.HorizontalListView
android:id="@+id/listview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:layout_marginLeft="70dp"
android:layout_marginRight="70dp"
android:layout_marginTop="50dp"
android:divider="#FFCC00"
android:fillViewport="false" >
</com.devsmart.android.ui.HorizontalListView>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
但是,当我尝试这种方法时发生了错误:这是 Log Cat:
12-26 11:09:16.350: E/AndroidRuntime(7102): FATAL EXCEPTION: main
12-26 11:09:16.350: E/AndroidRuntime(7102): java.lang.NullPointerException
12-26 11:09:16.350: E/AndroidRuntime(7102): at com.lluvia.digilib.DashboardActivity$HeavyWorker.onPostExecute(DashboardActivity.java:468)
12-26 11:09:16.350: E/AndroidRuntime(7102): at com.lluvia.digilib.DashboardActivity$HeavyWorker.onPostExecute(DashboardActivity.java:1)
12-26 11:09:16.350: E/AndroidRuntime(7102): at android.os.AsyncTask.finish(AsyncTask.java:590)
12-26 11:09:16.350: E/AndroidRuntime(7102): at android.os.AsyncTask.access$600(AsyncTask.java:149)
12-26 11:09:16.350: E/AndroidRuntime(7102): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:603)
12-26 11:09:16.350: E/AndroidRuntime(7102): at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 11:09:16.350: E/AndroidRuntime(7102): at android.os.Looper.loop(Looper.java:132)
12-26 11:09:16.350: E/AndroidRuntime(7102): at android.app.ActivityThread.main(ActivityThread.java:4123)
12-26 11:09:16.350: E/AndroidRuntime(7102): at java.lang.reflect.Method.invokeNative(Native Method)
12-26 11:09:16.350: E/AndroidRuntime(7102): at java.lang.reflect.Method.invoke(Method.java:491)
12-26 11:09:16.350: E/AndroidRuntime(7102): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
12-26 11:09:16.350: E/AndroidRuntime(7102): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
12-26 11:09:16.350: E/AndroidRuntime(7102): at dalvik.system.NativeStart.main(Native Method)
请帮助meeee :((((((