HELO, 我正试图在我的一个片段中实现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);
}
答案 0 :(得分:1)
查看更正后的版本
@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 view;
}