How to Disable EditText Keyboard Android App


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;
	}
}

}


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap