listview checkbox多選
private class inputlistviewadapter extends BaseAdapter {
private Activity inActivity;
private List<inputlistview> inputlistview_list;
private inputlistviewadapter(Activity activity, List<inputlistview> in
putlistview) {
super();
this.inActivity = activity;
this.inputlistview_list = inputlistview;
}
@Override
public int getCount() {
return inputlistview_list.size();
}
@Override
public Object getItem(int position) {
return inputlistview_list.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup pa
rent) {
if (convertView == null) {
LayoutInflater inflater = inActivity.getLayoutInflater();
convertView = inflater.inflate(R.layout.main_row, null);
}
TextView a = convertView.findViewById(R.id.textView5);
TextView b = convertView.findViewById(R.id.textView6);
final CheckBox checkBox = convertView.findViewById(R.id.checkBox);
a.setText(inputlistview_list.get(position).getTextView5());
b.setText(inputlistview_list.get(position).getTextView6());
if (editmode) {
checkBox.setVisibility(View.VISIBLE);
} else {
checkBox.setVisibility(View.GONE);
}
// checkBox.setText(inputlistview_list.get(position).toString());
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChan
geListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean
isChecked) {
if (checkBox.isChecked()==true){
}
}
});
return convertView;
}
}
}
請問一下要怎麼下手寫
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.136.103.44
※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1520417628.A.5D1.html
※ 編輯: kyand4010 (110.28.75.158), 03/07/2018 18:27:20
推
03/08 14:08,
6年前
, 1F
03/08 14:08, 1F
→
03/08 14:09,
6年前
, 2F
03/08 14:09, 2F
推
03/08 22:22,
6年前
, 3F
03/08 22:22, 3F
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章