public class ListPage extends ListActivity
{
TheLists a[] = new TheLists[1];
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.list_page);
setListAdapter(new MyAdapter());
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
class MyAdapter extends ArrayAdapter<TheLists>
{
MyAdapter()
{
super(ListPage.this, R.layout.list_row, R.id.sname, a);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.list_row,parent,false);
TextView name,category,id;
name=(TextView)row.findViewById(R.id.sname);
category=(TextView)row.findViewById(R.id.scategory);
id=(TextView)row.findViewById(R.id.sid);
name.setText(a[0].schemelist[position]);
category.setText(a[0].categorylist[position]);
id.setText(a[0].idlist[position]);
return(row);
}
}
}
}
我收到一个运行时错误,上面写着
05-02 18:56:32.224: E/AndroidRuntime(775): FATAL EXCEPTION: main
05-02 18:56:32.224: E/AndroidRuntime(775): java.lang.NullPointerException
05-02 18:56:32.224: E/AndroidRuntime(775): at com.example.listinflator_demo.ListPage$MyAdapter.getView(ListPage.java:75)
05-02 18:56:32.224: E/AndroidRuntime(775): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
需要什么改变?