可以有人解释我,为什么我在尝试setAdapter时有java.lang.NullPointerException?
当我尝试设置适配器时,我的arraylist已经填满了.我做错了什么?
谢谢!
activity_view_list.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/lvView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
item.xml
<?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">
<ImageView
android:id="@+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher">
</ImageView>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tvDescr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text=""
android:textSize="20sp">
</TextView>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的产品类
package com.shvedchenko.skleroshop;
/**
* Created by dima on 14.08.13.
*/
public class Product {
String name;
int image;
Product(String _describe, int _image) {
name = _describe;
image = _image;
}
} …Run Code Online (Sandbox Code Playgroud)