title: How to get tab click event in activity on TabLayout android
body: <p>This is the implementation of the onCreate method in my activity. I need to create the tabs dynamically. For simplicity, I made 2 tabs.</p>
  
  <pre class="lang-java prettyprint-override"><code>public class ActivityProductList extends AppCompatActivity {
  
      private android.support.v7.widget.SearchView searchView = null;
      private RecyclerView recyclerView;
      MyAdapter adapter;
      List&lt;ParentListItem&gt; parentListItems = new ArrayList&lt;&gt;();
      List&lt;ParentListItem&gt; originalProductList = new ArrayList&lt;&gt;();
      String query = null;
      int categoryId = 0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_products_final);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          getSupportActionBar().setTitle("PRODUCTS");
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          //ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
  
          TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
          tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
          tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
          //setupViewPager(viewPager);
          //tabLayout.setupWithViewPager(viewPager);
          //viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
  
          searchView = (android.support.v7.widget.SearchView) findViewById(R.id.searchView);
          searchView.setIconified(false);
          searchView.onActionViewExpanded();
          searchView.clearFocus();
          searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
              @Override
              public boolean onQueryTextSubmit(String query) {
                  if (adapter != null)
                      filterData(query);
                  return false;
              }
  
              @Override
              public boolean onQueryTextChange(String query) {
                  if (adapter != null)
                      filterData(query);
                  return false;
              }
          });
  
      }
  }
  </code></pre>
  
  <p>I want to change the <code>EditText</code> value on clicking on a tab. That <code>EditText</code> is in the same activity.</p>
  
  <p>How do I get Tab click event in Activity?</p>