1

I found few days ago, amazing project, called https://github.com/commonsguy/cwac-merge.

I want to make some adapter disabled (non clickable, like headers).

On readme I can read:

You can also extend MergeAdapter to override isEnabled(), so you can control which positions are and are not enabled.

But I cant realize, how can I do this. That is source isEnabled method:

  @Override
  public boolean isEnabled(int position) {
    for (ListAdapter piece : pieces) {
      int size=piece.getCount();

      if (position<size) {
        return(piece.isEnabled(position));
      }

      position-=size;
    }

    return(false);
  }

This is my adapter's adding code:

            adapter.addView(header("Header1"),false);
            SimpleAdapter test = new SimpleAdapter(Test.this, top, R.layout.main,  
                    new String[] { ITEM_TITLE2, ITEM_CAPTION2, ITEM_TITLE3 }, new int[] { R.id.id1, R.id.id2, R.id.id3 });
            adapter.addAdapter(test1);
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
sztembi
  • 223
  • 2
  • 10

1 Answers1

1

Step #1: Create your own custom subclass of SimpleAdapter.

Step #2: Override isEnabled() on your custom subclass, returning true and false as needed.

My apologies for the confusing language in the README -- I'll update that shortly.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491