我尝试增加图片片段。增加按钮没问题。 但今天我想增加他们编译错误的列表。 我怎么能这样做?。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.templistmune, container, false);
String[] glossary = {"C","B","A","K"
};
setListAdapter(new ArrayAdapter<String>(templistview.this, R.layout.listview_item, glossary));
//The method setListAdapter(ArrayAdapter<String>) is undefined for the type templistview
//error The constructor ArrayAdapter<String>(templistview, int, String[]) is undefined
ListView listView = getListView();
//error The method getListView() is undefined for the type templistview
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
});
return view;
}
答案 0 :(得分:0)
我发现将templistview.this更改为getActivity()
答案 1 :(得分:0)
您需要扩展ListActivity
MyActivity extends ListActivity
来源:"The method setListAdapter(ArrayAdapter) is undefined for the type create"