Showing posts with label EditText. Show all posts
Showing posts with label EditText. Show all posts

Thursday, June 27, 2013

How to stop EditText from gaining focus at Activity startup? - Android


I have an activity with EditText at the top and a ListView under it.. EditText takes focus as soon as the Activity starts.. and also the soft keyboard comes up..

To fix this problem, add the following code in your enclosing layout of EditText, ListView,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/mainLayout"
  android:descendantFocusability="beforeDescendants"
  android:focusableInTouchMode="true" >
and also remove

 <requestFocus />
from EditText.

Monday, April 8, 2013

Capitalize every letter in EditText - Android

I had an interesting usecase in my application, where I need to make EditText uppercase by default.

After googling it for a while found the solution,


EditText someText = (EditText) findViewById(R.id.someText);
someText.setInputType(0x00001001);



This will solve the problem :) Let me know if there are any alternate ways