If you do not want Android Soft Keyboard to be displayed for an EditText filed when it is brought to focus. Set setInputType(0) for EditText Object in onCreate() method.
editText = (EditText) findViewById(R.id.filed);
editText.setInputType(0);
The Keyboard will not appear when EditText is set to focus. Still, you can long-press on EditText to Copy/Cut/Select the text in the field.
package com.code2care.disableedittextexample;
public class DisableEditTextExample extends Activity {
private TextView textview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_text_demo);
editText = (EditText) findViewById(R.id.filed);
editText.setInputType(0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_edit_text_demo, menu);
return true;
}
}
}
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!