on onCreate method i am making all editText disable by using setFocusable method. But on button click i want to set focus again. I have implemented this , but now working.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contactform);
name = (EditText) findViewById(R.id.name);
email = (EditText) findViewById(R.id.email);
address = (EditText) findViewById(R.id.address);
phone_number = (EditText) findViewById(R.id.phone_number);
name.setFocusable(false);
address.setFocusable(false);
phone_number.setFocusable(false);
email.setFocusable(false);
}
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()){
case R.id.editButton:
Toast.makeText(this, "clicked", Toast.LENGTH_LONG).show();
name.setFocusable(true);
name.setFocusable(true);
address.setFocusable(true);
phone_number.setFocusable(true);
email.setFocusable(true);
break;
}
return super.onOptionsItemSelected(item);
}
Use :
setFocusable(true)
setFocusableInTouchMode(true)
Instead :
setEnabled(true)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.