private DrawerLayout drawerLayout; private FrameLayout fl; private ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); drawerLayout = (DrawerLayout) findViewById(R.id.drawerlayout); fl = (FrameLayout) findViewById(R.id.fl); iv = (ImageView) findViewById(R.id.iv); MainFragment01 mainFragment01=new MainFragment01(); iv.setImageResource(R.drawable.bg_account); getSupportFragmentManager().beginTransaction().replace(R.id.fl,mainFragment01).commit();}
布局文件
<FrameLayout android:id="@+id/fl" android:layout_width="match_parent" android:layout_height="match_parent" /> <ImageView android:id="@+id/iv" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" />
DrawerLayout的使用
最新推荐文章于 2025-07-25 15:30:17 发布