activity_main.xmlLinearLayoutxmlns:android=:tools=:layout_width=match_parentandroid:layout_height=match_parenttools:context=.MainActivityandroid:orientation=verticalTextViewandroid:layout_gravity=center_horizontalandroid:id=@+id/tvandroid:textSize=20spandroid:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:text=列表界面/LinearLayoutandroid:layout_weight=8android:layout_width=match_parentandroid:layout_height=0dpandroid:id=@+id/ll/LinearLayoutLinearLayoutandroid:layout_weight=1android:layout_width=match_parentandroid:layout_height=0dpButtonandroid:layout_weight=1android:id=@+id/btn_jichuandroid:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:text=@string/Base_map/Buttonandroid:layout_weight=1android:id=@+id/btn_yonghuandroid:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:text=@string/Location_User//LinearLayout/LinearLayoutfragment1.xml?xmlversion=1.0encoding=utf-8?LinearLayoutxmlns:android=:layout_width=match_parentandroid:layout_height=match_parentandroid:orientation=verticalcom.baidu.mapapi.map.MapViewandroid:id=@+id/bmapViewandroid:layout_width=fill_parentandroid:layout_height=fill_parentandroid:clickable=true//LinearLayoutfragment2.xml?xmlversion=1.0encoding=utf-8?RelativeLayoutxmlns:android=:layout_width=match_parentandroid:layout_height=match_parentcom.baidu.mapapi.map.MapViewandroid:id=@+id/bmapViewandroid:layout_width=fill_parentandroid:layout_height=fill_parentandroid:clickable=true/LinearLayoutandroid:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:layout_alignParentRight=trueandroid:layout_marginTop=80dipandroid:background=#D000android:minWidth=100dipandroid:orientation=verticalandroid:padding=2dpRadioGroupandroid:id=@+id/radioGroupandroid:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:contentDescription=定位iconRadioButtonandroid:id=@+id/defaulticonandroid:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:checked=trueandroid:text=默认图标/RadioButtonRadioButtonandroid:id=@+id/customiconandroid:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:text=自定义图标/RadioButton/RadioGroup/LinearLayoutButtonandroid:id=@+id/button1android:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:layout_alignParentRight=trueandroid:layout_alignParentTop=trueandroid:layout_marginRight=25dpandroid:layout_marginTop=10dip//RelativeLayout//主程序MainActivitypackagecom.example.zzhouzilong20151221;importcom.example.fragments.MyFragment1;importcom.example.fragments.MyFragment2;importandroid.R.color;importandroid.graphics.Color;importandroid.os.Bundle;importandroid.support.v4.app.FragmentActivity;importandroid.support.v4.app.FragmentManager;importandroid.support.v4.app.FragmentTransaction;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.widget.Button;importandroid.widget.LinearLayout;publicclassMainActivityextendsFragmentActivityimplementsOnClickListener{privateLinearLayoutll;privateButtonbtn1,btn2;privateFragmentManagerfm;MyFragment1mf1;MyFragment2mf2;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);init();}publicvoidinit(){//得到事务管理器fm=getSupportFragmentManager();//找控件ll=(LinearLayout)findViewById(R.id.ll);btn1=(Button)findViewById(R.id.btn_jichu);btn2=(Button)findViewById(R.id.btn_yonghu);FragmentTransactiontran=fm.beginTransaction();mf1=newMyFragment1();mf2=newMyFragment2();//添加fragment页tran.add(R.id.ll,mf1);tran.add(R.id.ll,mf2);//替换tran.replace(R.id.ll,mf1);tran.commit();//提交//设置颜色btn1.setBackgroundColor(Color.BLUE);btn1.setOnClickListener(this);btn2.setOnClickListener(this);}@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstubFragmentTransactiontran1=fm.beginTransaction();switch(v.getId()){caseR.id.btn_jichu:tran1.replace(R.id.ll,mf1);btn1.setBackgroundColor(Color.BLUE);btn2.setBackgroundColor(color.background_dark);break;caseR.id.btn_yonghu:tran1.replace(R.id.ll,mf2);btn2.setBackgroundColor(Color.BLUE);btn1.setBackgroundColor(color.background_dark);break;default:break;}tran1.commit();}}MyFragment1packagecom.example.fragments;importcom.baidu.mapapi.SDKInitializer;importcom.baidu.mapapi.map.MapView;importcom.example.zzhouzilong20151221.R;importandroid.os.Bundle;importandroid.support.v4.app.Fragment;importandroid.view.LayoutInflater;importandroid.view.View;importandroid.view.ViewGroup;publicclassMyFragment1extendsFragment{MapViewmMapView=null;@OverridepublicViewonCreateView(LayoutInflaterinflater,ViewGroupcontainer,BundlesavedInstanceState){//TODOAuto-generatedmethodstub//在使用SDK各组件之前初始化context信息,传入ApplicationContext//注意该方法要再setContentView方法之前实现SDKInitializer.initialize(getActivity().getApplicationContext());Viewview=inflater.inflate(R.layo