[windows phone]代码库
syLl.setOnClickListener(this);
flLl.setOnClickListener(this);
mlLl.setOnClickListener(this);
gwcLl.setOnClickListener(this);
wdLl.setOnClickListener(this);
public void addFragment(Fragment f){
FragmentManager manager=getSupportFragmentManager();
FragmentTransaction transaction=manager.beginTransaction();
if(fragment!=null){
transaction.hide(fragment);
}if(!f.isAdded()){
transaction.add(R.id.frame,f);
}
transaction.show(f);
transaction.commit();
fragment=f;
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.syLl:
if(homeFragment==null) {
homeFragment = new HomeFragment();
}
addFragment(homeFragment);
setColor(0);
setBackground(0);
break;
case R.id.flLl:
if(classifyFragment==null) {
classifyFragment = new ClassifyFragment();
}
addFragment(classifyFragment);
setColor(1);
setBackground(1);
break;
case R.id.mlLl:
if(meilaFragment==null) {
meilaFragment = new MeilaFragment();
}
addFragment(meilaFragment);
setColor(2);
setBackground(2);
break;
case R.id.gwcLl:
if(cartFragment==null) {
cartFragment = new CartFragment();
}
addFragment(cartFragment);
setColor(3);
setBackground(3);
break;
case R.id.wdLl:
if(mineFragment==null) {
mineFragment = new MineFragment();
}
addFragment(mineFragment);
setColor(4);
setBackground(4);
break;
}
}
初级程序员
by: 云代码会员 发表于:2019-10-21 14:40:56 顶(0) | 踩(0) 回复
0000
回复评论