我創建了一個簡單的優先級,顯示了AutoCompleteTextView控制時集中精力,它顯示正常,但是當我專注於AutoCompleteTextView並開始鍵入它帶來了鍵盤,但隨即失去焦點的控制。定製的Android偏好型失去打字
任何想法,爲什麼這失去了重點?
這是我做的創建視圖。膨脹的佈局只是一個基本的線性佈局,其中包含標題文本視圖。
我可以將其更改爲對話而不是偏愛我猜,但它會是平滑的,如果它可能是基本視圖的一部分。
@Override
protected View onCreateView(ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.base_preference, null);
if (mHint != null) {
TextView hintView = (TextView) layout.findViewById(R.id.PreferenceHintTextView);
hintView.setText(mHint);
}
TextView titleView = (TextView) layout.findViewById(R.id.PreferenceTitleTextView);
titleView.setText(getTitle());
AutoCompleteTextView inputView = new AutoCompleteTextView(getContext());
inputView.setGravity(Gravity.FILL_HORIZONTAL);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
R.layout.auto_complete_text_list_item,
getEntries());
inputView.setAdapter(adapter);
inputView.setThreshold(1);
inputView.setOnItemSelectedListener(this);
layout.addView(inputView);
return layout;
}
列表項是:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp"
android:textColor="#000">
</TextView>
可能已經可能已經標準的列表項,出來一樣。
我有類似的問題,但在我的情況下,我使用簡單的EditView。你找到解決方案嗎? – noisy 2011-02-16 17:10:22
一個演示項目將極大地幫助... – 2011-02-21 10:39:38
對不起,我沒有找到解決方案。我只是將它改成了一個對話偏好,它可以像預期的那樣工作,並且因爲它耗費大量時間而移動。如果我回到它並整理出來,我會發布解決方案。 – Brian 2011-02-22 05:58:02