I am making custom listview with different background and text color. I have overridden setSelected(int position) method from my custom adaptor. its is working Fine in 7 inch tabs but not working in Samsung Galaxy Note Tablet (10.1 inch).
if(selectedPosition == position){
((TextView)convertView.findViewById(R.id.folderName)).setTextColor(Color.WHITE);
((LinearLayout)convertView.findViewById(R.id.folderLayout)).setBackgroundResource(R.drawable.folders_list_bg_s);
}else{
((TextView)convertView.findViewById(R.id.folderName)).setTextColor(Color.BLACK);
((LinearLayout)convertView.findViewById(R.id.folderLayout)).setBackgroundResource(R.drawable.folders_list_bg);
}
And the setselection method as
public void setSelected(int position) {
selectedPosition = position;
}
After modifying the adapter we need to notify with notifyDatasetChanged() like
if(selectedPosition == position){
((TextView)convertView.findViewById(R.id.folderName)).setTextColor(Color.WHITE);
((LinearLayout)convertView.findViewById(R.id.folderLayout)).setBackgroundResource(R.drawable.folders_list_bg_s);
notifyDatasetChanged();
}else{
((TextView)convertView.findViewById(R.id.folderName)).setTextColor(Color.BLACK);
((LinearLayout)convertView.findViewById(R.id.folderLayout)).setBackgroundResource(R.drawable.folders_list_bg);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.