title: How to access views from view pager
body: <p>I am using view pager in my activity.I created views for 7 pages. Now i want to access page view inside my activity. I am getting data as blank.
  <strong><em>In Activity</em></strong></p>
  
  <pre><code>public class ActivitySingleEntry extends Activity implements OnClickListener {
  
      private ViewPager mPager;
      private FixedTabsView mFixedTabs;
  
      private ExamplePagerAdapter mPagerAdapter;
      private TabsAdapter mFixedTabsAdapter;
      private EditText edtFieldName;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_fixed_tabs);
          initViewPager(7, 0xFFFFFFFF, 0xFF000000);
          mFixedTabs = (FixedTabsView) findViewById(R.id.fixed_tabs);
          mFixedTabsAdapter = new FixedTabsAdapter(this);
          mFixedTabs.setAdapter(mFixedTabsAdapter);
          mFixedTabs.setViewPager(mPager);
  
      }
  
      private void initViewPager(int pageCount, int backgroundColor, int textColor) {
          mPager = (ViewPager) findViewById(R.id.pager);
          mPagerAdapter = new ExamplePagerAdapter(this, pageCount,
                  backgroundColor, textColor);
          mPager.setAdapter(mPagerAdapter);
          mPager.setCurrentItem(1);
          mPager.setPageMargin(5);
      }
  
      @Override
      public void onClick(View v) {
  
  //      LinearLayout lin=(LinearLayout) mPager.getChildAt(mPager.getCurrentItem());
  //      edtFieldName=(EditText) lin.findViewById(R.id.edtFieldName);
  //      Log.d("test", "From get child:"+edtFieldName.getText().toString()+":");
  
          Log.d("test", "Current Page:"+mPager.getCurrentItem());
  
          LinearLayout linearLayout=(LinearLayout) mPager.findViewWithTag("lin"+mPager.getCurrentItem());
          edtFieldName=(EditText) linearLayout.findViewById(R.id.edtFieldName);
  
          edtFieldName=(EditText) findViewById(R.id.edtFieldName);
          if (edtFieldName==null) {
              ShowToast.makeToast(getApplicationContext(), "Edt null");
          }else
          ShowToast.makeToast(getApplicationContext(),
                  "Data saved " + edtFieldName.getText().toString() + ":"
                          + mPager.getCurrentItem());
      }
  }
  </code></pre>
  
  <p><em><strong>My PageAdaper</em></strong></p>
  
  <pre><code>public class ExamplePagerAdapter extends PagerAdapter {
  
      protected transient Activity mContext;
  
      private int mLength = 0;
      private int mBackgroundColor = 0xFFFFFFFF;
      private int mTextColor = 0xFF000000;
  
      private String[] mData = { "Temperature", "Sugar", "BP", "Field 4",
              "Field 5", "Field 6", "Field 7" };
  
      public ExamplePagerAdapter(Activity context, int length,
              int backgroundColor, int textColor) {
  
          mContext = context;
          mLength = length;
          mBackgroundColor = backgroundColor;
          mTextColor = textColor;
  
      }
  
      @Override
      public int getCount() {
          return mLength;
      }
  
      @Override
      public Object instantiateItem(View container, int position) {
  
          LinearLayout linearLayout = (LinearLayout) View.inflate(mContext,
                  R.layout.activity_single_entry, null);
  
          TextView txtFieldName = (TextView) linearLayout
                  .findViewById(R.id.txtFieldName);
          EditText edtFieldName = (EditText) linearLayout
                  .findViewById(R.id.edtFieldName);
  
          String filedName = mData[position];
          txtFieldName.setText(filedName);
          edtFieldName.setHint("Please enter " + filedName);
          edtFieldName.setInputType(InputType.TYPE_CLASS_TEXT);
  
          if (filedName.equals("Temperature")) {
              edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER);
          } else if (filedName.equals("Sugar")) {
              edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER);
          } else if (filedName.equals("BP")) {
              edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER);
          }
  
  
          edtFieldName.setTag("edt");
  
          ((ViewPager) container).addView(linearLayout, 0);
          linearLayout.setTag("lin"+position);
  
          Log.d("test", "Adapter creating item:"+position );
          return linearLayout;
      }
  
  
  
      @Override
      public void destroyItem(View container, int position, Object view) {
          ((ViewPager) container).removeView((View) view);
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view == ((View) object);
      }
  
      @Override
      public void finishUpdate(View container) {
      }
  
      @Override
      public void restoreState(Parcelable state, ClassLoader loader) {
      }
  
      @Override
      public Parcelable saveState() {
          return null;
      }
  
      @Override
      public void startUpdate(View container) {
      }
  
  }
  </code></pre>
  
  <p>In R.layout.activity_single_entry xml i have edittext and button with onclick.</p>
  
  <p><em><strong>MYXml</em></strong>
      
      </p>
  
  <pre><code>    &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;TextView
              android:id="@+id/txtFieldName"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TextView" /&gt;
  
          &lt;EditText
              android:id="@+id/edtFieldName"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="10dp"
              android:layout_weight="1"
              android:hint="Please enter field value" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;Button
          android:id="@+id/btnSave"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="Save" 
          android:layout_margin="20dp"
          android:onClick="onClick"
          /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>If i used inside pageadapter</p>
  
  <pre><code>@Override
      public int getItemPosition(Object object) {
          // TODO Auto-generated method stub
          return POSITION_NONE;
      }
  </code></pre>
  
  <p>OnClick of button i want to access data from edit text. </p>
  
  <p>I able to get value for first page.Not for all.</p>