demo:
public class CityAqiFatherActivity extends BaseActivity { private CityAqiSortFragment rankingFragment=new CityAqiSortFragment();//站点排名 @Override protected int provideContentViewId() { return R.layout.activity_rank_father; } @Override protected void initView() { getSupportFragmentManager().beginTransaction().add(R.id.main_fragment,rankingFragment).commit(); } }
activity_rank_father.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/main_fragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> </LinearLayout> </LinearLayout>