String[] adobe_products = getResources().getStringArray(R.array.adobe_products);
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item_icc, R.id.label, adobe_products));
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String product = ((TextView) view).getText().toString();
我一直在尝试使用以下编辑过的代码片段
View view = inflater.inflate(R.layout.list_item_icc, parent, false);
ListView list = (ListView)getActivity().findViewById(R.id.listView1);
String[] adobe_products = getResources().getStringArray(R.array.adobe_products);
ArrayAdapter<String> arrayAdapter=new ArrayAdapter<String>(getActivity(), R.layout.list_item_icc, R.id.label, adobe_products);
list.setAdapter(arrayAdapter);
list.setClickable(true);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
setAdapter语句
中有错误答案 0 :(得分:2)
ListView list =(ListView)getActivity()。findViewById(R.id.listView1);
替换为
ListView list =(ListView)view.findViewById(R.id.listView1);
希望它能解决您的问题