<android.support.v4.widget.DrawerLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:id="@+id/Drawer_layout"
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/Framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@drawable/a"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_launcher_round"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:textColor="#f00"
android:text="lvxx" />
<TextView
android:id="@+id/one"
android:layout_marginTop="60dp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textColor="#fff"
android:layout_gravity="center_horizontal"
android:text="XListView上拉下拉"
android:textSize="20dp"/>
<TextView
android:id="@+id/two"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="ListView多条目"
android:textColor="#fff"
android:textSize="20dp"/>
<TextView
android:id="@+id/three"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Imageloder圆形图片"
android:textColor="#fff"
android:textSize="20dp"/>
<TextView
android:id="@+id/four"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Tablayout+viewpager"
android:textColor="#fff"
android:textSize="20dp"/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
package com.example.cela;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import com.example.cela.fragment.AFragment;
import com.example.cela.fragment.BFragment;
import com.example.cela.fragment.CFragment;
import com.example.cela.fragment.Dragment;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private TextView one;
private TextView two;
private TextView three;
private TextView four;
private AFragment aFragment;
private BFragment bFragment;
private CFragment cFragment;
private Dragment dFragment;
private DrawerLayout drawer_layout;
private FragmentManager manager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initData();
initView();
}
private void initData() {
aFragment = new AFragment();
bFragment = new BFragment();
cFragment = new CFragment();
dFragment = new Dragment();
}
private void initView() {
one = findViewById(R.id.one);
one.setOnClickListener(this);
two = findViewById(R.id.two);
two.setOnClickListener(this);
three = findViewById(R.id.three);
three.setOnClickListener(this);
four = findViewById(R.id.four);
four.setOnClickListener(this);
drawer_layout = findViewById(R.id.Drawer_layout);
manager = getSupportFragmentManager();
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.one:
manager.beginTransaction().replace(R.id.Framelayout,aFragment).commit();
drawer_layout.closeDrawers();
break;
case R.id.two:
manager.beginTransaction().replace(R.id.Framelayout,bFragment).commit();
drawer_layout.closeDrawers();
break;
case R.id.three:
manager.beginTransaction().replace(R.id.Framelayout,cFragment).commit();
drawer_layout.closeDrawers();
break;
case R.id.four:
manager.beginTransaction().replace(R.id.Framelayout,dFragment).commit();
drawer_layout.closeDrawers();
break;
}
}
}
615

被折叠的 条评论
为什么被折叠?



