2011-07-11 16 views
1

我有一個佈局,我將EditText控件的輸入類型設置爲android:inputType =「textCapCharacters」。在這個控件上工作得很好,但是仍然堅持,甚至將大寫屬性帶到其他應用程序。大寫卡住的Android EditText控件

這似乎是2.1英雄和2.3野火的情況。

有關我如何解除它的任何建議,或將鍵盤恢復爲默認模式?

謝謝

下面的代碼片段顯示出卡住的大寫行爲。我無法想象我是唯一有過這個問題的人。

點擊進入地址欄1,大寫單詞正常工作。在聚焦郵政編碼時,即使您轉到其他應用程序,無論您關注哪個其他控件(例如再次回到地址欄1),鍵盤都會正確切換爲大寫字母,但仍保持大寫字母。

應該指出,代碼似乎在仿真器中按預期工作,並且它只在物理設備上以大寫形式鎖定。

我現在知道,在英雄,至少,問題只存在於股票鍵盤上。當使用swiftkey鍵盤時,一切似乎都很好。

我已經在其他兩個論壇上發佈了這個問題,但沒有任何迴應,但Stackoverflow似乎是這類查詢的最佳建議,但是8天后我還沒有任何建議可以在這裏嘗試。如果更多信息,不同標籤或其他地方發佈對我來說是更好的選擇,我也很樂意聽到這些建議。

展示錯誤的完整和完整的代碼如下。

任何建議,任何人?

import android.app.Activity; 
import android.os.Bundle; 

public class Main extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
    } 
} 

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" android:layout_width="fill_parent"> 



    <TableLayout android:layout_width="fill_parent" android:id="@+id/tableLayout1" 
     android:layout_height="fill_parent" android:layout_margin="5dp" 
     android:stretchColumns="1"> 

     <TableRow> 
      <EditText android:textSize="17sp" android:layout_height="39dp" 
       android:layout_width="fill_parent" android:id="@+id/address" 
       android:hint="Address Line 1" android:layout_span="3" 
       android:inputType="textCapWords"></EditText> 
     </TableRow> 

     <TableRow> 
      <EditText android:inputType="textCapCharacters" 
       android:textSize="17sp" android:id="@+id/postcode" 
       android:layout_height="39dp" android:hint="Postcode" 
       android:layout_weight="1" android:layout_width="0dip"></EditText> 
      <CheckBox android:text="Check Me" 
       android:layout_height="39dp" android:id="@+id/checkme" 
       android:textSize="12sp" android:layout_weight="1" 
       android:layout_span="2" android:layout_width="0dip" 
       android:layout_gravity="center"></CheckBox> 
      <TextView android:layout_weight="1" android:layout_width="0dip"></TextView> 
     </TableRow> 
    </TableLayout> 
</LinearLayout> 
+0

得到同樣的問題,找不到解決方法:( – ZZZ

回答

0

如果你想顯示有資金的情況下鍵盤,然後而是採用android:inputType="textCapCharacters"的,你可以使用android:textAllCaps="true"。那麼你不會堅持大寫格式。然後爲了確保輸入是大寫的,你可以從EditText中調用檢索到的String的toUpperCase()方法。讓我知道你的想法。 Check this link for more clarity.