2
我有一個RecyclerView裏面viewPager。當我滾動查看尋呼機時,Recyclerview中的內容不正確。我試圖在onPageScrolled()和onResume()中調用notifyDataSetChanged()。但頁面滾動時內容仍不清晰。Recycler視圖裏面查看頁面滾動不刷新頁面滾動時
如何解決這個問題?在此先感謝
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { //viewPager.setOffscreenPageLimit(App.getInstance().getFragmentList().size());
favListAdapter.notifyDataSetChanged();
}
@Override
public void onPageSelected(int position) {
//favListAdapter.notifyDataSetChanged();
}
@Override
public void onPageScrollStateChanged(int state) {
});
@Override
public void onResume(){
if(favListAdapter!=null){
favListAdapter.notifyDataSetChanged();
}
super.onResume();
}
編輯:
我膨脹這樣的觀點:
@Override public RecyclerView.ViewHolder {
onCreateViewHolder(final ViewGroup viewGroup, int viewType) {
View v1 = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_add, viewGroup, false);
return new CellViewHolder(v1);
}
}
你的數據是靜態的還是動態的? –
是的,它獲取動態數據 – user8257041
你可以發佈'getView'代碼嗎? – ashwinx