您还没有初始化 Arraylist 项目并删除行位置 = 1;。执行以下操作:
package com.chigstuff.fun;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class MainListViewRecordAdapter extends ArrayAdapter<MainListViewRecord> {
private ArrayList<MainListViewRecord> items;
public MainListViewRecordAdapter(Context context, int textViewResourceId, ArrayList<MainListViewRecord> items) {
super(context, textViewResourceId, items);
this.items=items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.main_list_view_record, null);
}
MainListViewRecord item = items.get(position);
if (item != null) {
TextView main_list_view_text = (TextView) v.findViewById(R.id.main_list_view_text);
if (main_list_view_text != null) {
main_list_view_text.setText("What text");
}
}
return v;
}
}