I resolve my problem. Here my code
private List<TypeOfSupport> quoteToCashEngagementsList;
private List<TypeOfSupport> pointRequestsList;
private int positionCurItemInQuoteToCashList = -1;
private int positionCurItemInPointRequestList = -1;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_type_of_support);
Resources resources = getResources();
initQuoteToCashEngagements(resources);
initPointRequests(resources);
final TypeOfSupportAdapter quoteToCashAdapter = new TypeOfSupportAdapter(SelectionTypeOfSupport.this, R.layout.lv_type_of_support, quoteToCashEngagementsList);
final TypeOfSupportAdapter pointRequestsAdapter = new TypeOfSupportAdapter(SelectionTypeOfSupport.this, R.layout.lv_type_of_support, pointRequestsList);
final ListView quoteToCashListView = (ListView) findViewById(R.id.quote_to_cash_list);
quoteToCashListView.setAdapter(quoteToCashAdapter);
quoteToCashListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
if(positionCurItemInQuoteToCashList != -1){
quoteToCashEngagementsList.get(positionCurItemInQuoteToCashList).setChecked(false);
}
if(positionCurItemInPointRequestList != -1){
pointRequestsList.get(positionCurItemInPointRequestList).setChecked(false);
pointRequestsAdapter.notifyDataSetChanged();
}
quoteToCashEngagementsList.get(position).setChecked(true);
positionCurItemInQuoteToCashList = position;
quoteToCashAdapter.notifyDataSetChanged();
positionCurItemInPointRequestList = -1;
}
});
ListView pointRequestsListView = (ListView) findViewById(R.id.point_requests_list);
pointRequestsListView.setAdapter(pointRequestsAdapter);
pointRequestsListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
if(positionCurItemInPointRequestList != -1){
pointRequestsList.get(positionCurItemInPointRequestList).setChecked(false);
}
if(positionCurItemInQuoteToCashList != -1){
quoteToCashEngagementsList.get(positionCurItemInQuoteToCashList).setChecked(false);
quoteToCashAdapter.notifyDataSetChanged();
}
pointRequestsList.get(position).setChecked(true);
positionCurItemInPointRequestList = position;
pointRequestsAdapter.notifyDataSetChanged();
positionCurItemInQuoteToCashList = -1;
}
});
}
private class TypeOfSupportAdapter extends ArrayAdapter<TypeOfSupport> {
private Context context;
private List<TypeOfSupport> typeOfSupportList;
private int resourceId;
public TypeOfSupportAdapter(Context context, int resource, List<TypeOfSupport> objects) {
super(context, resource, objects);
this.context = context;
this.resourceId = resource;
this.typeOfSupportList = objects;
}
@Override
public TypeOfSupport getItem(int position) {
return typeOfSupportList.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
View rowView = layoutInflater.inflate(resourceId, parent, false);
TypeOfSupport curTypeOfSupport = typeOfSupportList.get(position);
TextView typeOfSupport = (TextView) rowView.findViewById(R.id.type_of_support);
typeOfSupport.setText(curTypeOfSupport.getTypeOfSupport());
ImageView checkImage = (ImageView) rowView.findViewById(R.id.img_checked_type);
if(curTypeOfSupport.isChecked()){
checkImage.setVisibility(View.VISIBLE);
} else {
checkImage.setVisibility(View.INVISIBLE);
}
return rowView;
}
}