//主Activity在获取到其view还没放进适配器里的时候进行更改
ViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.frame);
radioButton1.setBackgroundResource(R.drawable.ms1);
LayoutInflater lf = getLayoutInflater().from(this);
view1=lf.inflate(R.layout.food,null);
/***
* 为ViewPager的子页面控件进行监听
*/
view1.findViewById(R.id.imageButton01).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,FoodActivity.class);
startActivity(intent);
}
});
view2=lf.inflate(R.layout.menu,null);
view3=lf.inflate(R.layout.recommend,null);
view4=lf.inflate(R.layout.my,null);
List<View> list = new ArrayList<View>();
list.add(view1);
list.add(view2);
list.add(view3);
list.add(view4);
MyViewPagerAdapter myViewPagerAdapter=new MyViewPagerAdapter(list);
打开App,阅读手记