title: Get the value of an EditText from each tabs in a tablayout
body: <p>I need help on how to retrieve the userinput value from an edittext in a tablayout. I have 4 tabs and each tab have the same editText widget meaning that I only implemented one edittext view. Problem is, if I put a value in each editText I have no idea how to retrieve them since I don't know how to find the position for each editText considering that I only implemented it once in my layout. I even need to put them inside my database which is in sqlite. Would someone guide me. Thanks.</p>
  
  <p>My_Notes_Add_Main.java</p>
  
  <pre><code>package com.zaid.recyclerviewsqlite.addNotes;
  
  import android.os.Bundle;
  import android.support.design.widget.TabLayout;
  import android.support.v4.view.PagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.ImageButton;
  import android.widget.Toast;
  
  import com.zaid.recyclerviewsqlite.R;
  
  public class My_Notes_Add_Main extends AppCompatActivity implements View.OnClickListener {
  
      private final int numOfPages = 4; //viewpager has 4 pages
      private final String[] pageTitle = {"Terms", "Definition", "Syntax", "Code"};
      private ImageButton addNew;
      private EditText terms, def, syn, code;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.my_notes_add_main);
  
  
  
          addNew = (ImageButton)findViewById(R.id.addNew);
          addNewTerms();
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar1);
          setSupportActionBar(toolbar);
  
          TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
  
          for (int i = 0; i &lt; numOfPages; i++) {
              tabLayout.addTab(tabLayout.newTab().setText(pageTitle[i]));
          }
  
          //set gravity for tab bar
          tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
  
          final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
          final PagerAdapter adapter = new My_Notes_Add_MyPagerAdapter(getSupportFragmentManager(), numOfPages);
  
          viewPager.setAdapter(adapter);
          viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
          tabLayout.setOnTabSelectedListener(onTabSelectedListener(viewPager));
      }
  
      private TabLayout.OnTabSelectedListener onTabSelectedListener(final ViewPager pager) {
          return new TabLayout.OnTabSelectedListener() {
              @Override
              public void onTabSelected(TabLayout.Tab tab) {
                  pager.setCurrentItem(tab.getPosition());
              }
  
              @Override
              public void onTabUnselected(TabLayout.Tab tab) {
  
              }
  
              @Override
              public void onTabReselected(TabLayout.Tab tab) {
  
              }
          };
      }
  
    /**  @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.my_notes_add_main_menu, menu);        
          return true;
      } */
  
      public void addNewTerms(){
          addNew.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  Toast.makeText(getApplicationContext(), "Add Click", Toast.LENGTH_SHORT).show();
              }
  
      });
      }
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
      }
  
  
  
  
  
  
  }
  </code></pre>
  
  <p>My_Notes_Add_MyPagerAdapter.java</p>
  
  <pre><code>package com.zaid.recyclerviewsqlite.addNotes;
  
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentStatePagerAdapter;
  
  public class My_Notes_Add_MyPagerAdapter extends FragmentStatePagerAdapter {
      int numOfTabs;
  
      public My_Notes_Add_MyPagerAdapter(FragmentManager fm, int numOfTabs) {
          super(fm);
          this.numOfTabs = numOfTabs;
      }
  
      @Override
      public Fragment getItem(int position) {
  
         return My_Notes_Add_TabFragment.getInstance(position);
      }
  
      @Override
      public int getCount() {
          return numOfTabs;
      }
  }
  </code></pre>
  
  <p>My_Notes_Add_TabFragment.java</p>
  
  <pre><code>package com.zaid.recyclerviewsqlite.addNotes;
  
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.EditText;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import com.zaid.recyclerviewsqlite.R;
  
  public class My_Notes_Add_TabFragment extends Fragment {
  
      private int position;
      private TextView content;
      private ImageView image;
  
      public static Fragment getInstance(int position) {
          My_Notes_Add_TabFragment f = new My_Notes_Add_TabFragment();
          Bundle args = new Bundle();
          args.putInt("position", position);
          f.setArguments(args);
          return f;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //get data from Argument
          position = getArguments().getInt("position");
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          return inflater.inflate(R.layout.my_notes_add_tab_fragment, container, false);
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
  
  
          content = (EditText) view.findViewById(R.id.textView);
  
      }
  
  
  
  
  }
  </code></pre>