PagerAdapter
생성에서 직접 메서드에 액세스 할 때 나는 getViewAtPosition()
메서드를가집니다. 내가 참조를 사용하여 그것을 시도 할 때, 나는 할 수 없다. 나는 참조로 Acecces를 얻으려면 어떻게해야합니까? 여기참조로 메서드에 액세스 할 수 없습니다
내가 수 : 1 : 할 수 여기
: 2 :
public class CardapioRU extends Fragment {
private ViewPager mPager;
private PagerAdapter mPagerAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.view_pager_ru, container, false);
mPager = (ViewPager) rootView.findViewById(R.id.pager);
mPagerAdapter = new PagerAdapterRU(inflater);
mPager.setAdapter(mPagerAdapter);
return rootView;
}
}
.
public class PagerAdapterRU extends PagerAdapter {
private View domingo = null;
private View segunda = null;
@SuppressLint("InflateParams")
public PagerAdapterRU(LayoutInflater inflater) {
domingo = inflater.inflate(R.layout.ru_domingo, null);
segunda = inflater.inflate(R.layout.ru_segunda, null);
}
public View getViewAtPosition(int position) {
View view = null;
if (position == 0) {
view = domingo;
}
if (position == 1) {
view = segunda;
}
;
return view;
};
@Override
public Object instantiateItem(View collection, int position) {
View view = getViewAtPosition(position);
((ViewPager) collection).addView(view, 0);
return view;
}
@Override
public int getCount() {
return 2;
}
정말로 당신은 할 수 없습니까? 그것은 단지 IDE 버크가 아닙니다. – apokryfos
예, 단지 안드로이드 스튜디오 일 수 있습니다. 때로는 그것을 넣는 데 도움이되지 않을 수도 있습니다. 때로는 그것을 유효하게 생각하기 전에 컴파일하고 컴파일해야합니다. –
IDE 문제가 아니 었습니다, 이클립스는 괜찮습니다. 대답은 위에 있습니다. 감사합니다. –