0

我尝试增加图片片段。增加按钮没问题。但是今天我想增加他们编译错误的列表。我该怎么做?。

    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;

        }
4

2 回答 2

0

我发现将 templistview.this 更改为 getActivity()

于 2012-11-29T07:30:50.110 回答
0

您需要扩展 ListActivity

MyActivity extends ListActivity

来源:“方法 setListAdapter(ArrayAdapter) 未为类型创建定义”

于 2014-08-12T14:55:56.920 回答