我有一個列表視圖與圖像。當我選擇每個項目的圖像改變點擊image.But當我選擇另一個項目都圖像changes.I只想選擇的項目改變該image.it必須像單選按鈕mode.pls幫助單選按鈕。如何設置單一列表視圖與圖像的選擇模式
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);
}
}
});
}
}
請檢查以備將來參考** https://www.youtube.com/watch?v = s4JwU28VMko ** –