helo, 我試圖在我的片段之一實現autocompletetextview,但我堅持。AutoCompleteTextView沒有顯示片段中的建議
問題是autocompletetextview不顯示建議。我可以從textview讀取適配器,但它仍然無法正常工作。
public class fragment_dodajpodroz extends Fragment {
AutoCompleteTextView myAutoComplete;
String item[]={
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String DEBUG_TAG = "BAZA DANYCH";
Context c = getActivity().getApplicationContext();
View view = inflater.inflate(R.layout.dodajpodroz, container, false);
myAutoComplete = (AutoCompleteTextView)view.findViewById(R.id.autoCompleteTextView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String> (c, android.R.layout.simple_dropdown_item_1line, item);
myAutoComplete.setAdapter(adapter);
return inflater.inflate(R.layout.dodajpodroz, container, false);
}
,而不是'C'使用'getActivity()' – Raghunandan
回報視圖,而不是dodajpodroz – pskink
@pskink再膨脹 - 你的答案是偉大的! thans :) – tworzywohh