Cannot enable/disable clickable TextView inside GridView
<p>I have a GridView with clickable TextViews as GridView items, using an Adapter (the TextViews serve as Buttons). When I click on a TextView, I want to disable all over TextViews in the GridView - disable in the sense that the user cannot click them anymore. What I did is this:</p>

<pre><code>    private void toggleButtonsState(boolean enabled)
    {
        for (int i = 0; i &lt; this.gridview.getChildCount(); i++)
        {
            this.gridview.getChildAt(i).setEnabled(enabled);            
        }
    }   
</code></pre>

<p>However, even though this code is called with enabled == false, the buttons are still enabled. What wrong here? How can I get the other TextViews disabled? Thanks!</p>

<hr>

<p>I did what you said and implemented BaseAdapter directly. However, again these 2 methods never get called: neither at the beginning nor upon notifyDataSetChanged. Really don't know what's going on. Here is the code:</p>

<pre><code>public class TextViewAdapter extends BaseAdapter implements View.OnClickListener  {

@Override
public boolean areAllItemsEnabled() {
    // TODO Auto-generated method stub
    return super.areAllItemsEnabled();
}

@Override
public boolean isEnabled(int position) {
    // TODO Auto-generated method stub
    return super.isEnabled(position);
}

protected Context mContext;         

public TextViewAdapter(Context c)
{           
    this.mContext = c;      
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return DbManager.getInstance(mContext).getCategoryCount(true);
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return arg0;
}


@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public View getView(int arg0, View convertView, ViewGroup arg2) {           

    final LinearLayout linearLayout;          

    if (convertView == null) {  // if it's not recycled, initialize some attributes

        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        linearLayout = (LinearLayout)inflater.inflate(R.layout.settings_timer_textview, null);
        TextView textView = (TextView)linearLayout.findViewById(R.id.timer_textview);           
        textView.setOnClickListener(this);                          

    } else {
        linearLayout = (LinearLayout) convertView;
    }


    setCategoryView(linearLayout, arg0);    
    setControls(linearLayout, arg0);

    return linearLayout;

}

private void setControls(LinearLayout linearLayout, int index)
{
    TextView textView = (TextView)linearLayout.findViewById(R.id.timer_textview);
    Category category = getCategory(index);
    textView.setTag(category);                  
    textView.setText(category.getName());            
    textView.setTextColor(TimeManagerActivity.getForeColorByBrightness(category.getColor()));           
    textView.setBackgroundDrawable(createTextViewDrawable(category.getColor()));

    CheckBox checkbox = (CheckBox)linearLayout.findViewById(R.id.timer_checkbox);       
    checkbox.setChecked(category.getEnabled() != 0);        
    checkbox.setTag(textView.getText().toString());
}

protected Category getCategory(int index)
{
    return DbManager.getInstance(this.mContext).getCategoryByIndex(index, true);
}

protected void setCategoryView(View view, int index)
{
    // TODO Auto-generated method stub      

    TextView textView = (TextView)view.findViewById(R.id.timer_textview);       
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40));

    CheckBox checkbox = (CheckBox)view.findViewById(R.id.timer_checkbox);
    checkbox.setVisibility(View.GONE);
}

@Override
public void onClick(View arg0)
{       
    // TODO Auto-generated method stub      
    this.notifyDataSetChanged();
}   

public void update()
{
    this.notifyDataSetChanged();
}

private StateListDrawable createTextViewDrawable(int color)
{               
    // Create a gradient for the button. Height is hardcoded to 30 (I don't know the height beforehand). 
    // I wish I could set the gradient aligned to the bottom of the button.
    final Shader shader = new LinearGradient(0, 0, 0, 0,
        new int[] { color, color },
        null, Shader.TileMode.MIRROR);          

    float[] roundedCorner = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
    ShapeDrawable normal = new ShapeDrawable(new RoundRectShape(roundedCorner, null, null));

    normal.getPaint().setShader(shader);
    normal.setPadding(3, 3, 3, 3);

    // Create a state list (I suppressed settings for pressed).             
    StateListDrawable state_list = new StateListDrawable();
    state_list.addState(new int[] { }, normal);

    return state_list;
}
</code></pre>

<p>}</p>

<hr>

<p>Here is my class derived from <code>TextViewAdapter</code> which itself is derived from <code>BaseAdapter</code>. My <code>TextViewAdapter</code> just defines some abstract methods and doesn't do much. The <code>TextViewApaterMain</code> tries to disable all TextViews in the Grid except for the one that was clicked on. In <code>OnClick</code> I click a TextView and want to disable all other TextViews, so I call <code>notifyDataSetChanged</code>, but the overrides <code>areAllItemsEnabled</code> and <code>isEnabled</code> are not called (debugger doesn't stop at breakpoint). Any ideas? Here's some code:</p>

<pre><code>public class TextViewAdapterMain extends TextViewAdapter  {

private ArrayList&lt;Boolean&gt; textViewStates = new ArrayList&lt;Boolean&gt;();

public TextViewAdapterMain(Context c) {
    super(c);


    // TODO Auto-generated constructor stub
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return DbManager.getInstance(mContext).getCategoryCount(true);
}

@Override
protected void setCategoryView(View view, int index) {
    // TODO Auto-generated method stub      

    TextView textView = (TextView)view.findViewById(R.id.timer_textview);       
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40));

    CheckBox checkbox = (CheckBox)view.findViewById(R.id.timer_checkbox);
    checkbox.setVisibility(View.GONE);
}   

@Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub
    super.onClick(arg0);

    ((TimeManagerActivity)super.mContext).launchChronometer((TextView)arg0);


    this.notifyDataSetChanged();
}

@Override
protected Category getCategory(int index) {
    // TODO Auto-generated method stub
    return DbManager.getInstance(this.mContext).getCategoryByIndex(index, true);
}

@Override
public boolean areAllItemsEnabled() {
    return false;
}

@Override
public boolean isEnabled(int position)
{                           
    if(textViewStates.get(position))
        return true;

    return false;

}

}
</code></pre>
