title: Where should I put my code in ActionBar.TabListener
body: <p>I have just started with an ActionBar.TabListener with 3 tabs.
  I selected new "Tabbed activity" in Android Studio.
  My activity is called test...not the best name but I'm just trying to learn:)</p>
  
  <p>I have a listView in fragment_test.xml that I want to fill with data after a raw sql search.
  If I put this code in onCreateView then everytime I click on a tab it will re-write that tab with the same info in the listView.
  What I want is to have diffrent information in those tabs.... then I need to know which tab that is clicked. That I did with mViewPager.getCurrentItem() ....Is this right? How can i get the name of the tab instead?</p>
  
  <p>I have also found onTabSelected...should I put my code here? In this case I think I know which tab that is selected but is it really wise to put the code here?
  If I do this then listView1 becomes null...why?:</p>
  
  <pre><code>public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
          listView1 = (ListView)findViewById(R.id.listView2);
          listAdapter2 = new ArrayAdapter&lt;String&gt;(context, R.layout.simplerow, testArray);
          listAdapter2.notifyDataSetChanged();
          listView1.setAdapter(listAdapter2);
  </code></pre>
  
  <hr>
  
  <pre><code>    &lt;ListView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/listView2"
          android:layout_centerHorizontal="true" /&gt;
  </code></pre>