使用Android Studio过程中遇到的一些问题总结

1、在使用Activity集成AppCompatActivity时

 首先引包老是出错,找不到AppCompatActivity,明明SDK下边有该包。这个错误发生在打开两个Android Studio时,关掉其中一个就正常了。

2、This Activity already has an action bar supplied by the window decor

 正常引入AppCompatActivity后,如果调用:

Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

 就会闪退,捕获异常发现错误是:

This Activity already has an action bar supplied by the window decor……

 查找到的解决方式:

 I think you're developing for Android Lollipop, but anyway include this line: false to your theme declaration inside of your app/src/main/res/values/styles.xml.
 Also, if you're using AppCompatActivity support library of version 22.1 or greater, add this line:
true

 Your theme declaration may look like this after all these additions:


你可能感兴趣的:(使用Android Studio过程中遇到的一些问题总结)