View.setFocusable() and View.setClickable() have contrary effect in custom ArrayAdapter

This is a follow up to this question where Reimar Twelker suggested using View.setFocusable() and View.setClickable() to enable/disable rows in a list view using an ArrayAdapter.

I tried doing this, but I get the opposite effect to what I would expect.
If I use

  • Only using Proguard: Could not init DaoConfig => ArrayIndexOutOfBoundsException
  • What is Android's equivalent to Apple's b2b program?
  • Show Pie chart in Android Application
  • Eclipse Upgrade Not Working
  • Android: How to switch between Activities like switching desktops in Home app?
  • View.setFocusable(true);

    the row is disabled (no effect when I press it). And if I use the opposite:


    the row is enabled (selection applied when I press it).

    Any clue about what might be happening?

    Here is the contents of my layout:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android=""
      <ImageView android:id="@+id/row_image_style"
        android:drawingCacheQuality="low" />

    I use it in an alert dialog like this:

    dialog = new AlertDialog.Builder(this)
                .setAdapter(new StyleAdapter(this,, StyleTemplate.values()), 
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {

    and StyleAdapter is defined as follows:

    public class StyleAdapter extends ArrayAdapter<StyleTemplate>{
            private final StyleTemplate[] m_objects;
            private final LayoutInflater inflater;
            public StyleAdapter(Context context, int textViewResourceId, StyleTemplate[] objects) {
                super(context, textViewResourceId, objects);
                m_objects = objects;
                inflater = getLayoutInflater();
            public View getView(int position, View convertView, ViewGroup parent) {
                View row = convertView;
                if (row == null) { // Reuse the old view if it exists
                    row = inflater.inflate(R.layout.row_style, parent, false);
                // Get the selected style data
                StyleTemplate style = m_objects[position];
                // Set the background image to the template background
                ImageView bg = (ImageView) row.findViewById(;
                bg.setBackgroundColor(Color.rgb(style.bR, style.bG, style.bB));
                boolean val = true;
                return row;

    To test the effect of setFocusable() and setClickable(), I simply change the value of val in StyleAdapter.getView().

    Related posts:

    &#039;adb&#039; is not recognized as an internal or external command, operable program or ba...
    How do I make tabs for a ViewPager now that ActionBar tabs are deprecated (Lollipop)
    Brightness Screen Filter
    Activity instance still exists even after onDestroy() is called
    Where is the output from an android instrumented test?
    Appcompat Alert Dialog Action button background On pressed state
  • Neither user nor current process has android.permission.ACCESS_COARSE_LOCATION
  • Android ListView background colors always showing grey
  • How to get text direction in Android and change layout dynamically according to the direction?
  • Android Facebook chat example project
  • How to clear distinct_id in mixpanel android when user logs out?
  • From Web Development to Android Development
  • One Solution collect form web for “View.setFocusable() and View.setClickable() have contrary effect in custom ArrayAdapter”

    Actually here I found the explanation of it all. The thing is that if you set the view to be clickable, then it will consume the click and not propagate it to the container.

    Thus convertView.setClickable(true) actually disables the clicks.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.