如何使用TabLayout在Fragment中使用CardView行實現(xiàn)RecyclerView我想在一個使用TabLayout的Activity中實現(xiàn)一個ListFragment,這樣我就可以在不同的列表之間滑動。最后它應(yīng)該成為一個預(yù)訂應(yīng)用程序,以便您可以選擇不同的學(xué)科,并預(yù)訂一個特定的時間段。然而到目前為止,我只實現(xiàn)了ListActivity或標(biāo)簽活動(android studio中的標(biāo)準(zhǔn)活動),但不是兩者。如果有人可以提供幫助,我會很高興的。標(biāo)簽式活動:public class Diciplines extends AppCompatActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diciplines);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
如何使用TabLayout在Fragment中使用CardView行實現(xiàn)RecyclerView
函數(shù)式編程
2019-08-16 16:31:54