2012-05-01 30 views
1

我有一些AutoCompleteTextView輸入字段的android應用AutoCompleteTextView清除上HTC Desire Z的用戶輸入

他們的工作我的手機上很好,

然而,當應用程序部署到手機與物理鍵盤,當用戶「選項卡」 從一個AutoCompleteTextView到另一個,他們已經選擇或輸入的文本從視圖

消失然而的數據仍然存在,並且被永久保存到底層數據庫

爲什麼這隻發生在他們的手機上而不是所有的時間?

回答

1

我看到一個非常類似的事情發生在HTC Desire HD(沒有物理鍵盤)上。每當AutoCompleteTextView失去焦點時,文本似乎消失(但仍可通過getText()訪問)。例如,同樣的應用可以在三星Galaxy SIII上正常工作。

我認爲這是連接到使用樣式/主題。在我的情況,我有一個android:textViewStyle定義,但沒有android:autoCompleteTextViewStyle。用明智的android:textColor添加後者解決了問題。您也可以使用setTextColor。從我的styles.xml

摘錄:

<style name="myapp" parent="@style/Theme.Sherlock.Light"> 
    <item name="android:textViewStyle">@style/my_text_view</item> 
    <item name="android:autoCompleteTextViewStyle">@style/my_ac_text_view</item> 
    [...] 
</style> 

<style name="my_text_view" parent="@android:style/Widget.TextView"> 
    <item name="android:textColor">@color/my_text_color</item> 
</style> 

<style name="my_ac_text_view" parent="android:style/Widget.AutoCompleteTextView"> 
    <item name="android:textColor">@color/my_text_color</item> 
</style> 
+0

斯特凡感謝您花時間看這個。我相信你是正確的,因爲它是使用風格的根本原因 – Hector

1

我遇到同樣的問題與Desire HD的。我將android:textColor="#000000"設置爲AutoCompleteTextView,並且無需修改任何樣式即可解決此問題。