1

私は EditText を持っていimeOptions="actionSearch"ます。EditText をクリックすると、HTC Desire S や HTC Incredible など、一部の HTC デバイスでキーボードが表示されません。EditText xml は次のとおりです。

<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" />

DroidSansEditTextEditTextのカスタムdroid-sans fontです。DroidSansEditText は次のとおりです。

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

2 に答える 2