2014-02-14 20 views
0

我想顯示數字鍵盤。即使我已將inputType設置爲數字編輯文本,也會顯示文本鍵盤android

這是我的代碼來做到這一點。 (這是我列表中的一項)。

 <?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/checked_list_item_text" 
     android:layout_width="500dp" 
     android:layout_height="wrap_content" 
     android:layout_toLeftOf="@+id/checked_list_item_quatity"   
     android:layout_centerVertical="true" 
     android:textSize="30sp" /> 

    <EditText 
     android:id="@+id/checked_list_item_quatity" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_marginLeft="7dp" 
     android:gravity="center_vertical" 
     android:hint="Quantité" 
     android:focusableInTouchMode="true" 
     android:inputType="number" 
     android:maxLength="6" 
     android:textSize="30sp" /> 

</RelativeLayout> 

當我點擊的EditText,鍵盤顯示的數字,但很快切換到文本,我必須單擊第二次拿到數字鍵盤。

此問題僅在我第一次打開該活動時發生。

+0

你可能想解釋一下你在這裏發佈的代碼是做什麼的。 – Mark

回答

0

你應該有什麼工作,但它可能是代碼方面的東西。也許你可以強制程序:

EditText checkedInput = (EditText) findViewById(R.id.checked_list_item_quatity); 
checkedInput.setInputType(InputType.TYPE_CLASS_NUMBER); 
1

嘗試改變輸入模式,在你的AndroidManifest.xml

試圖讓集中到一個列表視圖中一個EditText場這就是當我有同樣的問題。在持有listview的活動中添加android:windowSoftInputMode =「adjustPan」爲我解決了問題。

<activity android:name=".MyEditTextInListView" 
      android:label="@string/app_name" 
      android:windowSoftInputMode="adjustPan"> 
相關問題