2
我想用自定義單選按鈕(單選項目選項)自定義列表視圖(每個項目一個圖像&一個文本)。android自定義列表視圖與自定義單選按鈕
我的代碼:
listview.setAdapter(new myAdapter(getApplicationContext(),
R.layout.mycontent, text));
我Adapter類:
public class myMessageAdapter extends ArrayAdapter<String> {
private LayoutInflater mInflater;
private String[] mText = null;
long id;
private int mViewResourceId;
public myMessageAdapter(Context ctx, int viewResourceId,
ArrayList<String> textList) {
super(ctx, viewResourceId);
mInflater = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
String[] message = textList.toArray(new String[textList.size()]);
mText = message;
mViewResourceId = viewResourceId;
}
@Override
public int getCount() {
return mText .length;
}
@Override
public String getItem(int position) {
return mText [position];
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(mViewResourceId, null);
TextView MESSAGE = (TextView) convertView.findViewById(R.id.message);
id = getItemId(position);
MESSAGE.setText(mText [position]);
return convertView;
}
}
我的輸出列表項應該是:
<radioButton> <Text> <Image>.Single choice selection.How could i do that?
檢查這些爲解決http://www.mysamplecode.com/2012/07/android-listview-checkbox-example.html,HTTP:// www.jmanzano.es/blog/?p=166 – kumar 2013-03-21 06:16:15