小弟剛剛接觸android 問題可能有點簡單,還請見諒。
如題,我先新增了AS default可以選擇有negative drawer的activity作為MAIN之後
新增了另一個negative drawer在 新建的activity(一樣繼承AppCompatActivity)
接著也複製了跟Main相同的code(包含重建兩個main,bar兩個的layout)
java裏頭的code也是直接複製過去,可是只要一跑就會crash,不知道是哪裡出了問題
希望能尋求版上大大協助orz,非常感謝。
附上我的CODE
public class informationActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_info);
getSupportActionBar().setTitle("Information");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar2);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout2);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
informationActivity.this, drawer, toolbar,
R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView)
findViewById(R.id.nav_view2);
navigationView.setNavigationItemSelectedListener(this);