Iterate the container layout view and treat the views depending what widget they're instances of. For example if you wanted to hide all Button
and disable all EditText
:
for(int i=0; i < layout.getChildCount(); i++) {
View v = layout.childAt(i);
if (v instanceof Button) {
v.setVisibility(View.GONE); //Or View.INVISIBLE to keep its bounds
}else
if (v instanceof EditText) {
((EditText)v).setEnabled(false);
}
}
Of course if you wan to add other properties such as making it not clickable or whatever you'd just add them in the correspondent if from the previous code.
Then to hide the keyboard:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
A cleaner way of doing this (if you know the ids of the views) is to store them in int[]
and the loop over that instead of getting al children views from the layout, but as far as the result goes, they're pretty much the same.