I have been doing this for about 3 days, browsing various sites for reference, but I'm stuck. I use a swipe and tab layout that gives you a standard snippet fragment. But I have 3 separate fragments that I want to display for different .xml layouts. This is the section of code that bothers me:
import java.util.Locale; import android.app.ActionBar; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class MainActivity extends FragmentActivity implements ActionBar.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
This returns fragment 2. I want to display 3 fragments when each tab is selected. How can I do it? I guess this is what returns correctly?
edit .. ive included the entire java .. class in the hope that I could change that. How to use FragmentPagerAdapter to place tabs with different content? ive tried the following (second answer, since I did not understand what it meant in the first), it did not work
jamie source share