我正在使用 com.android.support:appcompat-v7:23.0.3
使用 appcompat
制作 Android 应用程序并出现以下错误。
Error:(22, 9) error: method setSupportActionBar in class AppCompatActivity cannot be applied to given types; required: android.support.v7.widget.Toolbar found: android.widget.Toolbar reason: actual argument android.widget.Toolbar cannot be converted to android.support.v7.widget.Toolbar by method invocation conversion
最佳答案
首先,appcompat 23.0.3 不存在。
使用23.0.1
com.android.support:appcompat-v7:23.0.1
然后 method setSupportActionBar
与 android.support.v7.widget.Toolbar
配合使用。
检查代码中的导入。
当您使用工具栏
时,您必须使用正确的导入:
import android.support.v7.widget.Toolbar;
最后,在您的布局中,您必须使用正确的小部件。
<android.support.v7.widget.Toolbar
..... />
关于android - 如何解决 Android 错误 "method setSupportActionBar in class AppCompatActivity cannot be applied to given types"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32678542/