AutoCompleteTextView autoCompView =
(AutoCompleteTextView) findViewById(R.id.autocomplete_city);
给我一个错误
对于 CityFragment 类型,方法 findViewById 未定义。
和:
public class CityFragment extends Fragment {
public CityFragment() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.city,
container, false);
AutoCompleteTextView autoCompView =
(AutoCompleteTextView) findViewById(R.id.autocomplete_city);
autoCompView.setAdapter(
new PlacesAutoCompleteAdapter(this, R.layout.list_item)
);
return rootView;
}
}
我基本上只是从https://developers.google.com/places/training/autocomplete-android复制了代码
任何想法为什么我会收到错误?