我正在使用此代码处理简单的列表视图,
public class RadioDemoActivity extends Activity {
ArrayList<String> list = new ArrayList<String>();
MyListAdapter mla;
ListView lv;
int position = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv = (ListView) findViewById(R.id.listView1);
list.add("one");
list.add("two");
list.add("three");
list.add("four");
list.add("five");
list.add("six");
list.add("seven");
list.add("eight");
list.add("nine");
list.add("ten");
list.add("eleven");
list.add("twelve");
list.add("thirteen");
list.add("fourteen");
list.add("fifteen");
list.add("sixteen");
list.add("seventeen");
list.add("eightteen");
list.add("nineteen");
list.add("twenty");
mla = new MyListAdapter(this);
lv.setAdapter(mla);
}
public class MyListAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public MyListAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return list.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.cust_list, null);
TextView tv = (TextView)convertView.findViewById(R.id.txt_title);
ImageView iv = (ImageView)convertView.findViewById(R.id.imageView1);
tv.setText(list.get(position));
Log.v("log_tag","position In"+list.get(position));
}
return convertView;
}
}
}
但结果就像十一点后的图像中显示的一,一,二。请帮我