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

}



Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.