On HTC Desire S, the soft keyboard does not appear on the EditText focus

advertisements

I am having an EditText with imeOptions="actionSearch". Now when I click on EditText, the keyboard does not pop up in some of HTC Devices, like HTC Desire S & HTC Incredible. EditText xml is as follow:

<com.myapp.utilities.font.DroidSansEditText
                    android:id="@+id/txtSearchByName"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="0.60"
                    android:background="@drawable/edittext"
                    android:ellipsize="end"
                    android:gravity="left|center_vertical"
                    android:hint="@string/provider_practice"
                    android:imeOptions="actionSearch"
                    android:inputType="textCapWords"
                    android:paddingLeft="10dp"
                    android:paddingRight="5dp"
                    android:singleLine="true"
                    android:tag="byName"
                    android:textColor="#a19d93"
                    android:textSize="15.5sp" />

DroidSansEditText is the custom EditText having droid-sans font. The DroidSansEditText is as follow :

public class DroidSansEditText extends EditText {
    public DroidSansEditTextView(Context context) {
        super(context);
    }

    public DroidSansEditTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DroidSansEditTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public void setTypeface(Typeface tf, int style) {
        if (!isInEditMode()) { //For Graphical layout of xml in eclipse
            // here Bold style is handled. Same way we can handle italic style
            if (style == 1) { // if bold (Style Constant, normal = 0 | bold = 1
                                // | italic = 2)
                tf = Typeface.createFromAsset(getContext()
                        .getApplicationContext().getAssets(),
                        "DroidSans-Bold.ttf");
            } else {
                tf = Typeface.createFromAsset(getContext()
                        .getApplicationContext().getAssets(), "DroidSans.ttf");
            }
            super.setTypeface(tf, 0);
        }
    }
}


maybe because actually you do not set typeface if this EditText is in edit mode?

I mean, why do you need that:

 if (!isInEditMode())

if in edit mode you want to set another typeface, write else statement and set this another typeface in it.

Because as for now - if TextView is in Edit Mode you don't call super.setTypeface(); so you just override method and do nothing in it. Please try and let me know