ViewPager로 2개의 Layout을 불러내서

2page로 된 화면을 만들었습니다.

 

public Object instantiateItem(View pager, int position) {
   View v = null;
   if (position == 0) {
    v = mInflater.inflate(R.layout.main, null);
    int btnid = R.id.main_btn_01;
    for (int i = 0; i < BTN_COUNT; i++) {
     v.findViewById(btnid + i)
       .setOnClickListener(mClickListener);
    }

   }
   else if (position == 1) {
    v = mInflater.inflate(R.layout.main_2, null);
   }
   ((ViewPager) pager).addView(v, 0);
   return v;
  }

 

여기서 질문입니다.

 

main_2.xml에 있는 TextView에 Java 소스로 setText 할 수 있는 방법이 있을까요?

position == 1일때

v = mInflater.inflate(R.layout.main_2, null);

TextView tv = (TextView)findViewById(R.id.text);

tv.setText("텍스트");

 

이렇게 소스를 짜니까 에러가 납니다;

ViewPager를 전개할때 텍스트를 쓰는 방법 없을까요?