是否可以返回一个视图(ListView中的一行)?
我想禁用所有的复选框:
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);
}
}
非常类似的函数,您可以在Robotium源代码中找到,特别是在类ViewFetcher中。或者你可以使用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;
}