Reputation: 568
I have tried to disable and enable the focusing of edittext box depend on checkbox. While checkbox is checked, the textbox is focusable and if it is not checked, the textbox should be non-focusable. When i tried to enable focusing the text box after disable the textbox using the checkbox, it is not working. Here is my code.
check_box.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if(isChecked){
txt_time.setFocusable(true);
} else {
txt_time.setFocusable(false);
}
}
});
Thanks in advance..
Upvotes: 0
Views: 437
Reputation: 7071
Instead of
txt_time.setFocusable(true);
try
txt_time.setEditable(true);
Upvotes: 0
Reputation: 132992
try
enable:
txt_time.setFocusableInTouchMode(true);
txt_time.setFocusable(true);
disable:
txt_time.setFocusableInTouchMode(false);
txt_time.setFocusable(false);
instead of
enable:
txt_time.setFocusable(true);
disable:
txt_time.setFocusable(false);
Upvotes: 1