다음은 PagerAdapter의 예입니다. 조각을 가져 와서 instantiateItem의 모든 로직을 작성하는 대신 컨테이너에 추가 할 수 있습니까? 사전에조각을 사용하는 PagerAdapter
감사
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view=null;
if(position%2==0){
view = activity.getLayoutInflater().inflate(R.layout.pager_item,container, false);
}else{
view = activity.getLayoutInflater().inflate(R.layout.pager_item,container, false);
}
// Add the newly created View to the ViewPager
container.addView(view);
// Retrieve a TextView from the inflated View, and update it's text
TextView title = (TextView) view.findViewById(R.id.item_title);
title.setText(tabs[position]);
// Return the View
return view;
}
한 가지가 있다는 것입니다 * *이 이동 데이터 세트를 처리하기 위해 만들어지는 것이 아니다. 항목을 삽입하거나 이동하는 경우 데이터 세트가 변경되었음을 알리는 것뿐만 아니라 새 어댑터를 만들어야합니다. 다른 경우에는 훌륭합니다. :) – kcoppock
@ kcoppock 감사합니다! 이것은 나를 미치게했다. 나는 당신이 그것을 거기에 두지 않고 어떻게 내 마음에 들어가기로되어 있었는지 잘 모르겠습니다. – kandinski