編輯:關於Android編程
//在Activity中加載顯示隱藏Fragment import android.app.Activity; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Intent; import android.os.Bundle; import com.commons.Config; import com.geluyawangluo.withthenight.activitymy.SignInActivity; import com.geluyawangluo.withthenight.fragment.CatFragment; import com.geluyawangluo.withthenight.fragment.ClassificationFragment; import com.geluyawangluo.withthenight.fragment.InformationFragment; import com.geluyawangluo.withthenight.fragment.MyFragment; import com.geluyawangluo.withthenight.fragment.ShoppingFragment; import com.geluyawangluo.withthenight.widget.ScreenManager; import com.geluyawangluo.withthenight.widget.TabBar; public class MainActivity extends Activity { private TabBar tabBar; private CatFragment catFragment; private ClassificationFragment classificationFragment; private InformationFragment informationFragment; private MyFragment myFragment; private ShoppingFragment shoppingFragment; private FragmentManager fm; private FragmentTransaction transaction; private Config config; private int ind=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabBar=(TabBar)findViewById(R.id.tabBar); ScreenManager.getInstance().addActivity(this); config=Config.getInstance(); tabBar.addTab(R.mipmap.qt1_12,R.mipmap.qt1_12, "商城"); tabBar.addTab(R.mipmap.huodongimage,R.mipmap.huodongimage, "活動"); tabBar.addTab(R.mipmap.shequimage,R.mipmap.shequimage, "社區"); tabBar.addTab(R.mipmap.qt1_15,R.mipmap.qt1_15, "購物車"); tabBar.addTab(R.mipmap.qt1_16,R.mipmap.qt1_16, "我的"); fm=getFragmentManager(); transaction=fm.beginTransaction(); catFragment = new CatFragment(); classificationFragment=new ClassificationFragment(); myFragment=new MyFragment(); shoppingFragment=new ShoppingFragment(); informationFragment = new InformationFragment(); transaction.add(R.id.id_content,shoppingFragment); transaction.add(R.id.id_content,classificationFragment); transaction.add(R.id.id_content,informationFragment); transaction.add(R.id.id_content,catFragment); transaction.add(R.id.id_content,myFragment).commit(); tabBar.setTabShouldChange(new TabBar.TabShouldChange() { @Override public boolean shouldChange(int index) { // TODO Auto-generated method stub if (index == 0) { getFragmentManager().beginTransaction().hide(catFragment).hide(myFragment).hide(classificationFragment).hide(informationFragment).show(shoppingFragment).commit(); ind=0; } else if (index == 1) { getFragmentManager().beginTransaction().hide(catFragment).hide(myFragment).hide(shoppingFragment).hide(informationFragment).show(classificationFragment).commit(); ind=1; } else if (index == 2) { getFragmentManager().beginTransaction().hide(catFragment).hide(myFragment).hide(shoppingFragment).hide(classificationFragment).show(informationFragment).commit(); ind=2; }else if (index == 3) { // setCatFragment(); getFragmentManager().beginTransaction().hide(informationFragment).hide(myFragment).hide(shoppingFragment).hide(classificationFragment).show(catFragment).commit(); ind=3; }else if (index == 4) { String land=config.getString("uid"); if(land.length()<1){ Intent intent=new Intent(); intent.putExtra("main","main"); intent.setClass(MainActivity.this, SignInActivity.class); startActivity(intent); tabBar.setSelectedndex(ind); return false; }else{ getFragmentManager().beginTransaction().hide(informationFragment).hide(catFragment).hide(shoppingFragment).hide(classificationFragment).show(myFragment).commit(); ind=4; } } return true; } }); // setShoppingFragment(); Intent intent=this.getIntent(); if(intent!=null){ String mark=intent.getStringExtra("mark"); if(mark!=null&&mark.equals("feilei")){ getFragmentManager().beginTransaction().hide(catFragment).hide(myFragment).hide(shoppingFragment).hide(informationFragment).show(classificationFragment).commit(); tabBar.setSelectedndex(1); ind=1; }else{ getFragmentManager().beginTransaction().hide(catFragment).hide(myFragment).hide(classificationFragment).hide(informationFragment).show(shoppingFragment).commit(); } } } }
//Fragment顯示隱藏的時候會調用
//Fragment中的onHiddenChanged方法在這裡可以更新界面數據
@Override public void onHiddenChanged(boolean hidden) { super.onHiddenChanged(hidden); } }
由於我的版本最低是2.2,所以只有把源碼下下來自己改,如果你覺得太多了可自己編譯成jar引用,本人不才,對java不是很熟悉,如果此版本中有錯誤還請大家指出來,此圖顯示的
OV88651、kernel部分:A、kernel_driver:把驅動文件ov8865_qtech_f8865ac.c 放到kernel/drivers/media/p
話說為了防止偷拍,業內有不成文規定,手機公司在做camera時,點擊拍照和錄像鍵的時候,必須要有提示音。因此,google也就非常人性化的將播放拍照聲音的函數,放到了ca
三星s7微信消息推送收不到怎麼辦?不少用戶反映手機出現爆音、收不到微信、qq消息推送,那麼三星s7微信不提示怎麼辦?三星s7收不到微信消息推送怎麼解決?下文