title: Send data from main activity listview to detail activity with fragment using Tab Layout
body: <p>I am new in Android Development and I don't know how to pass data from main activity with Listview to select particular product and go to new activity with fragement tablayout...I want to know how can I get data in fragment tablayout from main activity...Thanks </p>
  
  <p>MainActivity.java
  <i>
    import packages...</p>
  
  <pre><code>  public class HomeActivity extends AppCompatActivity {
  
    String s_firstname, s_lastname, s_password, s_email, Err;
    TextView fname,lname,email,password,err,sid;
    private DrawerLayout drawerLayout;
    private Toolbar toolbar;
    private ListView lv;
    private List&lt;String&gt; classList;
    private FloatingActionButton fab;
    Context ctx=this;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);
      toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      initNavigationDrawer();
  
      lv = (ListView) findViewById(R.id.listView);
  
      SharedPreferences ui = this.getSharedPreferences("UserInfo", Context.MODE_PRIVATE);
      String s_id = ui.getString("s_id","s_id");
      new SignupActivity(this).execute(s_id);
  
      lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              String c_name = (String) lv.getItemAtPosition(position);
              Intent intent = new Intent(HomeActivity.this,ClassDetailsActivity.class);
              intent.putExtra("c_name", c_name);
              startActivity(intent);
          }
      });
  
      fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent intent = new Intent(HomeActivity.this,JoinclassActivity.class);
              startActivity(intent);
          }
      });
     }
   }
  </code></pre>
  
  <p></i></p>
  
  <p>DetailsProduct.java</p>
  
  <p><i></p>
  
  <pre><code>public class ClassDetailsActivity extends AppCompatActivity {
  
  private Toolbar toolbar;
  private TabLayout tabLayout;
  private ViewPager viewPager;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_class_details);
      String name = getIntent().getExtras().getString("c_name");
      viewPager = (ViewPager) findViewById(R.id.viewpager);
      setupViewPager(viewPager);
      tabLayout = (TabLayout) findViewById(R.id.tabs);
      tabLayout.setupWithViewPager(viewPager);
  }
  
  private void setupViewPager(ViewPager viewPager) {
      ViewPagerAdapter adapter = new  ViewPagerAdapter(getSupportFragmentManager());
      adapter.addFragment(new EventFragment(), "Event");
      viewPager.setAdapter(adapter);
  }
  
  class ViewPagerAdapter extends FragmentPagerAdapter {
      private final List&lt;Fragment&gt; mFragmentList = new ArrayList&lt;&gt;();
      private final List&lt;String&gt; mFragmentTitleList = new ArrayList&lt;&gt;();
  
      public ViewPagerAdapter(FragmentManager manager) {
          super(manager);
      }
  
      @Override
      public Fragment getItem(int position) {
          return mFragmentList.get(position);
      }
  
      @Override
      public int getCount() {
          return mFragmentList.size();
      }
  
      public void addFragment(Fragment fragment, String title) {
          mFragmentList.add(fragment);
          mFragmentTitleList.add(title);
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return mFragmentTitleList.get(position);
      }
    }
  }
  </code></pre>
  
  <p></i></p>
  
  <p>OneFragement.java</p>
  
  <p><i></p>
  
  <pre><code>public class EventFragment extends Fragment {
  TextView tv;
  
  public EventFragment() {
      // Required empty public constructor
  }
  
  @Override
  public void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      return inflater.inflate(R.layout.fragment_event, container, false);
  
        }
  
   }
  </code></pre>
  
  <p></i></p>