0

Is it possible to return a view (a row in a ListView) ?

I want to disable all the checkboxes:

public void disableCheckboxes()
{       
    for(int i =0; i < getCount(); i++)
    {
        View view = (View) getView(i, null, null);
        CheckBox checkBox = (CheckBox)view.findViewById(R.id.playlist_checkbox);
        checkBox.setVisibility(CheckBox.INVISIBLE);
    }
}
Johan
  • 79
  • 9
  • This question is a duplicate of http://stackoverflow.com/questions/257514/android-access-child-views-from-a-listview. Please find your answer there :) – Adel Boutros Dec 22 '11 at 09:41

1 Answers1

0

Very similar function you can find in Robotium source code, especially at class ViewFetcher. Or you can use Robotium.

public ArrayList<View> getAllViews(boolean onlySufficientlyVisible) {
    final View[] views = getWindowDecorViews();
    final ArrayList<View> allViews = new ArrayList<View>();
    final View[] nonDecorViews = getNonDecorViews(views);


    if (views != null && views.length > 0) {
        View view;
        for(int i = 0; i < nonDecorViews.length; i++){
            view = nonDecorViews[i];
            try {
                addChildren(allViews, (ViewGroup)view, onlySufficientlyVisible);
            } catch (Exception ignored) {
            }
        }
        view = getRecentDecorView(views);
        try {
            addChildren(allViews, (ViewGroup)view, onlySufficientlyVisible);
        } catch (Exception ignored) {
        }
    }
    return allViews;
}
Lesya Makhova
  • 1,340
  • 3
  • 14
  • 28