• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps problem with choosing a listview item and updating it

guigo170

Lurker
Hello I am trying to work with the setTag view method to detect what items is pressed. my layout is composed of a list each row containing a textfield a togglebutton and an imageview. I would like to change the image of the row containing the pressed button but i have no method to change the image of a specific imageview object depending on its tag. I have gone this far and i'm stuck on how to continue can i get some help please?



[HIGH] Collections.sort(myArr, String.CASE_INSENSITIVE_ORDER);
setListAdapter(new MyAdapter(this, android.R.layout.simple_list_item_1,
R.id.textView1,
(String[]) myArr.toArray(new String[]{})));
}

class MyAdapter extends ArrayAdapter<String>{

private int which;

public MyAdapter(Context context, int resource,
int textViewResourceId, String[] string) {
super(context, resource, textViewResourceId, string);
// TODO Auto-generated constructor stub
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.custom_view, parent,false);
final TextView tv = (TextView) row.findViewById(R.id.textView1);
final ImageView iv = (ImageView) row.findViewById(R.id.imageView1);
final ToggleButton tb = (ToggleButton) row.findViewById(R.id.toggleButton1);

tv.setTag(position);
iv.setTag(position);
tb.setTag(position);

tv.setText(myArr.get(position).toString());

tb.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
if(tb.isChecked()){
which=(Integer) tb.getTag();


}else{

}


}
});

return row;
}
}

}[/HIGH]
 

Attachments

  • andrhelp.jpg
    andrhelp.jpg
    37.9 KB · Views: 73
Back
Top Bottom