我制作了一个不错的 ViewPager,现在,我希望用户在屏幕上双击时,底部菜单栏会出现/消失。我认为这会很容易,但是在阅读了很多论坛并尝试了许多潜在的解决方案之后,我不得不承认我无法实现。:-(
谁能为此提供完整的代码解决方案?
提前致谢。
这是我的基本代码:
public class ActivityMain extends FragmentActivity
{
static final int NUM_PAGES = 3;
CustomFragmentStatePagerAdapter fragment_pager_adapter;
ViewPager view_pager;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fragment_pager_adapter = new CustomFragmentStatePagerAdapter(getSupportFragmentManager());
view_pager = (ViewPager) findViewById(R.id.view_pager);
view_pager.setAdapter(fragment_pager_adapter);
}
public static class CustomFragmentStatePagerAdapter extends FragmentStatePagerAdapter
{
public CustomFragmentStatePagerAdapter(FragmentManager fm)
{
super(fm);
}
@Override
public int getCount()
{
return NUM_PAGES;
}
@Override
public Fragment getItem(int position)
{
Fragment fragment = null;
switch (position)
{
case 0:
fragment = new Fragment0();
break;
case 1:
fragment = new Fragment1();
break;
case 2:
fragment = new Fragment2();
break;
}
return fragment;
}
}
}