I have a listview with image.When i select each item the image changes to clicked image.But when i select another item both images changes.I want only the selected item to change the image.it has to function like radio button with single choice mode.pls help.
public class ProvierActivity extends Activity {
private String text[] = { "BroadStripe-Cable (Seattle)", "BroadStripe-Digital (Seattle)",
"BroadStripe-Cable (Seattle)", "Comcast king county south)", "BroadStripe-Cable (Seattle)",
"Comcast king county south", "BroadStripe-Digital (Seattle)", "BroadStripe-Digital (Seattle)",
"BroadStripe-Cable (Seattle)", "Comcast king county south" };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ListView list = (ListView) findViewById(R.id.listview_id);
list.setAdapter(new ArrayAdapter<String>(this, R.layout.list,
R.id.title, text));
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view,
int position, long arg3) {
// TODO Auto-generated method stub
if (view.findViewById(R.id.img).getVisibility() == ImageView.VISIBLE) {
ImageView icon = (ImageView) view.findViewById(R.id.img);
icon.setImageResource(R.drawable.checked);
}
}
});
}
}