MarkMjw / PullToRefresh

根据Maxwin的XListView改造而来,完善下拉刷新上拉加载更多的功能并实现自动刷新以及自动加载等功能, 并增加对ScrollView的支持。 原XListView参考链接:https://github.com/Maxwin-z/XListView-Android
Apache License 2.0
690 stars 322 forks source link

adapter點擊事件無效 #8

Closed oliguo closed 9 years ago

oliguo commented 9 years ago

我嘗試在initView尾添加

mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView textView=(TextView)view.findViewById(R.id.list_item_text); Toast.makeText(view.getContext(),textView.getText(), Toast.LENGTH_SHORT); } });

代碼:

private void initView() { mHandler = new Handler(); mListView = (XListView) findViewById(R.id.list_view); mListView.setPullRefreshEnable(true); mListView.setPullLoadEnable(true); mListView.setAutoLoadEnable(true); mListView.setXListViewListener(this); mListView.setRefreshTime(getTime()); mAdapter = new ArrayAdapter(this, R.layout.vw_list_item, items); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView textView=(TextView)view.findViewById(R.id.list_item_text); Toast.makeText(view.getContext(), textView.getText(), Toast.LENGTH_SHORT); } }); }

希望實現點擊對應item時獲取對應內容,運行后發現沒有觸發成功,請教下是不是思路哪裡有錯,謝謝

oliguo commented 9 years ago

原來漏了show,馬虎了。。。。。

Toast.makeText(view.getContext(), textView.getText(), Toast.LENGTH_SHORT).show();

MarkMjw commented 9 years ago

OK. closed issue.