目前我使用viewpager做旋轉木馬菜單viewpager更新的TextView(如粗體)
這裏是如何我設置的viewpager
name = menu.substring(b, menu.length() - 1);//just some strings
fragments = getFragments();
pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments);
pager = (ViewPager) findViewById(R.id.viewpager);
pager.setPageMargin(-700);
pager.setOffscreenPageLimit(Menu.size());
pager.setAdapter(pageAdapter);
pager.setOnPageChangeListener(pageAdapter);
pager.setCurrentItem(pager.getAdapter().getCount() - 1, false);
pager.setPageTransformer(true, new ZoomOutPageTransformer());
private List<Fragment> getFragments() {
fList.add(MyFragment.newInstance(name));
return fList;
}
然後我pageadapter類
class MyPageAdapter extends FragmentPagerAdapter implements ViewPager.OnPageChangeListener {
private List<Fragment> fragments;
private FragmentManager fm;
public MyPageAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fm = fm;
this.fragments = fragments;
}
@Override
public Fragment getItem(int position) {
return this.fragments.get(position);
}
@Override
public int getCount() {
return this.fragments.size();
}
@Override
public void onPageScrollStateChanged(int state) {
}
@Override
public void onPageSelected(int arg0) {
}
}
這裏是MyFragment類
public static final MyFragment newInstance(String message) {
MyFragment f = new MyFragment();
bdl = new Bundle(1);
bdl.putString(EXTRA_MESSAGE, message);
f.setArguments(bdl);
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
String message = getArguments().getString(EXTRA_MESSAGE);
v = inflater.inflate(R.layout.myfragment_layout2, container, false);
TextView messageTextView = (TextView) v.findViewById(R.id.textView);
messageTextView.setText(message);
return v;
}
我想更新的TextView messageTextView大膽當視圖是在中間,而其他的TextView的視圖的其餘部分取消粗體,像下面
任何人的圖片可以幫助我如何去做這個?謝謝!