I have a custom listview adapter which contains two buttons, the problem is it’s hard to click on the button and it keeps losing focus, or you have to touch it multiple times before it recognizes the click.
@Override
public View getView(int position, View view, final ViewGroup parent) {
DataEntity data = entityList.get(position);
view = inflater.inflate(R.layout.new_mission_row, parent, false);
// inflate other views
Button playButton = (Button) view.findViewById(R.id.buttonPlay);
playButton.setBackgroundResource(R.drawable.blue_button);
playButton.setTextColor(Color.WHITE);
MyClickListener listener = new MyClickListener(context,entity);
playButton.setOnClickListener(listener);
playButton = (Button) view.findViewById(R.id.buttonMap);
playButton.setBackgroundResource(R.drawable.blue_button);
playButton.setTextColor(Color.WHITE);
playButton.setOnClickListener(listener);
return view;
}
Check your code once. You have not created a different button object for
buttonmap.Here you are using the same button object as you have created for
buttonPlayAlso when your are populating the ListView then you should use the ViewHolder pattern to populate the listview efficiently.