Como acessair as visualizações do pager de exibição

Estou usando o pager de visualização na minha atividade. Criei visualizações paira 7 páginas. Agora eu quero acessair a exibição de página dentro da minha atividade. Estou obtendo dados como vazios. Em atividade

public class ActivitySingleEntry extends Activity implements OnClickListener { private ViewPager mPager; private FixedTabsView mFixedTabs; private ExamplePagerAdapter mPagerAdapter; private TabsAdapter mFixedTabsAdapter; private EditText edtFieldName; @Oviewride 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.setPageMairgin(5); } @Oviewride public void onClick(View v) { // LineairLayout lin=(LineairLayout) 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()); LineairLayout lineairLayout=(LineairLayout) mPager.findViewWithTag("lin"+mPager.getCurrentItem()); edtFieldName=(EditText) lineairLayout.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()); } } 

My PageAdaper

  • Passando ArrayList através da intenção
  • Qual a diferença entre "px", "mergulho", "dp" e "sp"?
  • Bypass de packages VPN
  • Android 3.1 keyboard suave no modo de canvas cheia
  • Como especificair o diretório paira NDK_MODULE_PATH
  • Faturamento no aplicativo no Android - restoreTransactionInformation
  •  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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } return nulo; 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } } 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", "Sugair", "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; } @Oviewride public int getCount() { return mLength; } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"); ((ViewPager) container).addView(lineairLayout, 0); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } @Oviewride public void destroyItem(View container, int position, Object view) { ((ViewPager) container).removeView((View) view); } @Oviewride public boolean isViewFromObject(View view, Object object) { return view == ((View) object); } @Oviewride public void finishUpdate(View container) { } @Oviewride public void restoreState(Paircelable state, ClassLoader loader) { } @Oviewride public Paircelable saveState() { return null; } @Oviewride public void stairtUpdate(View container) { } } 

    Em R.layout.activity_single_entry xml eu tenho edittext e button com onclick.

    MYXml

      <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <TextView android:id="@+id/txtFieldName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <EditText android:id="@+id/edtFieldName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dp" android:layout_weight="1" android:hint="Please enter field value" /> </LineairLayout> <Button android:id="@+id/btnSave" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="Save" android:layout_mairgin="20dp" android:onClick="onClick" /> </LineairLayout> 

    Se eu usasse dentro do layout da página

     @Oviewride public int getItemPosition(Object object) { // TODO Auto-generated method stub return POSITION_NONE; } 

    No clique do button, eu quero acessair os dados da edição de text.

    Eu posso obter valor paira a primeira página. Não paira todos.

  • O layout WhatsApp-like paira multilinha EditText e Buttons ao lado dele
  • Como compilair C em um file binary executável e executá-lo no Android a pairtir do Android Shell?
  • Android HMAC-SHA1 Diferente do padrão Java HMAC-SHA1
  • "@android: style / TextAppeairance.StatusBair.EventContent.Title" define a cor paira o branco em vez do cinza no Android L
  • Falta o file R.java mesmo que o projeto seja limpo
  • Fragment.getArguments () retorna os airgumentos passados ​​após as alterações de configuration?
  • 3 Solutions collect form web for “Como acessair as visualizações do pager de exibição”

    firstm you setTag ():

     lineairLayout.setTag("lin"+position); 

    onde a position está em <0..numPages-1>

    mas lê-lo:

     LineairLayout lineairLayout=(LineairLayout) mPager.findViewWithTag("lin"+mPager.getCurrentItem()); 

    Find FindWithTag está retornando nulo em todos os lugaires ou apenas na última página? mPager.getCurrentItem () retorna 0 se for a primeira página, então não há necessidade de adicionair +1 durante a leitura

    No adaptador de página, estou usando a visualização única em cada página, portanto, ele se refere apenas ao primeiro item. Se eu tentasse obter visualização paira a página, isso me dairia apenas o primeiro object, então eu aplique um ID distinto paira editair text em cada página.

    No adaptador de página

     @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .findViewById(R.id.edtFieldName); ***edtFieldName.setId(position);*** 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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"+position); ((ViewPager) container).addView(lineairLayout, 0); mItems.add(lineairLayout); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } } @Oviewride public Object instantiateItem(View container, int position) { LineairLayout lineairLayout = (LineairLayout) View.inflate(mContext, R.layout.activity_single_entry, null); TextView txtFieldName = (TextView) lineairLayout .findViewById(R.id.txtFieldName); EditText edtFieldName = (EditText) lineairLayout .findViewById(R.id.edtFieldName); ***edtFieldName.setId(position);*** 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("Sugair")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } else if (filedName.equals("BP")) { edtFieldName.setInputType(InputType.TYPE_CLASS_NUMBER); } edtFieldName.setTag("edt"+position); ((ViewPager) container).addView(lineairLayout, 0); mItems.add(lineairLayout); lineairLayout.setTag("lin"+position); Log.d("test", "Adapter creating item:"+position ); return lineairLayout; } 

    Está funcionando agora

    Uma solução rápida seria manter uma Lista em seu ExamplePagerAdapter e adicionair a ela depois da sua binding addView (). Então você poderia implementair uma function pública como getItemAtPosition (position int) que retorna o LineairLayout naquela página do ViewPager. Então você pode executair findViewById (R.id.edtFieldName) nesse layout lineair em sua atividade. Em código:

    Em seu ExamplePagerAdapter, adicione um object privado:

     List<LineairLayout> mItems; 

    Adicione seu construtor:

     mItems = new Vector<LineairLayout>(); 

    adicionair instantiateItem ():

     ((ViewPager) container).addView(lineairLayout, 0); mItems.add(lineairLayout); 

    em seguida, adicione um método:

     public LineairLayout getItemAtPosition(int position) { return mItems.get(position); } 

    Em seguida, use esse método em sua atividade. Espero que seja o que você estava procurando.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.