0
새로운 기능 pageradapter를 사용하여 조각의 텍스트를 설정하려고 할 때 문제가 있습니다.PagerAdapter 클래스에서 단편의 텍스트 뷰를 변경하는 방법
조각 (Fragment) 레이아웃에는 TextView가 1 개 있습니다.
public class Cau1 extends Fragment {
public TextView texview1;
public static String texthere = null;
public Cau1() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_, container, false);
texview1 = (TextView)rootView.findViewById(R.id.textView1);
texview1.setText(texthere);
return rootView;
}
내 어댑터는 다음과 같습니다
public class MyPagerAdapter extends FragmentPagerAdapter {
public MyPagerAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int arg0) {
Fragment fragment = null;
if(arg0 == 0)
{
fragment = new Cau1();
Cau1.texthere = "This is page 1";
}
if(arg0 == 1)
{
fragment = new Cau1();
Cau1.texthere = "This is page 2";
}
if(arg0 == 2)
{
fragment = new Cau1();
Cau1.texthere = "This is page 3";
}
return fragment;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 3;
}
는 3 페이지가 있습니다. 그 결과는 다음과 같습니다
첫 페이지 :이 페이지 1
두 번째 페이지입니다 :이 페이지 2
세 번째 페이지입니다 :이 제발 도와주세요 3 페이지
입니다. 당신의 조각에서