I have a listView which contains ImageView,TextView and Checkbox. I added arraylist into listview. When I try to pass other activity with selecting checkbox, I just pass one line. However, I want to pass more than one.The last checkbox which I clicked in list always pass to other activity. Even if I select checkboxes are false(removing mark), it pass to other activity(If it is last checkbox I clicked). I think I have problems with checkboxes. I have searched but I haven't find solution.
private class ViewHolder {
ImageView img;
TextView name;
CheckBox checkBox;
}
public PersonListAdapter(Context context, int resource, ArrayList<myTasks> objects) {
super(context, resource, objects);
mContext = context;
mResource = resource;
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//get the persons information
setupImageLoader();
final String name = getItem(position).getTaskName();
String imgUrl = getItem(position).getImageURL();
final Boolean check = getItem(position).getCheckBox(); //(I dont use this can be problem, I dont know)
//ViewHolder object
final ViewHolder holder;
if(convertView == null){
LayoutInflater inflater = LayoutInflater.from(mContext);
convertView = inflater.inflate(mResource, parent, false);
holder= new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.newTaskTitle);
holder.img = (ImageView) convertView.findViewById(R.id.newImage);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.checkBox);
result = convertView;
convertView.setTag(holder);
}
else{
holder = (ViewHolder) convertView.getTag();
result = convertView;
}
holder.name.setText(name);
holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
intent.putExtra("RESULT_TEXT", name);
}
}
});
(StartActivity etc. in other methods like toolbar)
Aucun commentaire:
Enregistrer un commentaire