android - 按钮的属性编辑器弄乱了 onClick 值(在括号中插入类名)

标签 android android-studio android-studio-2.2

刚升级到 Android Studio 2.2 并在 layout.xml 的设计 View 中使用属性编辑器作为按钮。从那里我可以从我的 Activity 中选择方法,但是在我选择一个方法之后,一个错误的值将被插入到 onClick-Attribute 中:

例如:如果我选择“doStuff”方法,它就变成了

"android:onClick="get (MainActivity)"

当然这是行不通的,在运行时会抛出以下错误:

java.lang.IllegalStateException: Could not find method doStuff (MainActivity)(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'buttonDoStuff'

那么我在使用 Property-Editor 时做错了什么还是这是一个错误?

有时我的方法会在 Property-Editor 的 onClick 字段中多次显示。

最佳答案

我在 Android Studio 2.2 上遇到了同样的问题。

对我来说,它不会更改方法的名称,还会将“(MainActivity)”添加到属性中。我在文本编辑器中删除了那部分,现在它工作正常。

关于android - 按钮的属性编辑器弄乱了 onClick 值(在括号中插入类名),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39854629/

相关文章:

android - Dagger2 错误 : Cannot provide without @Inject constructor

android - dexguard 8.2.16 运行时崩溃

android - 缺少 Google Play 服务

android - 如何指示 Gradle 从不同位置使用 Java?

实现数据绑定(bind)时 Android Studio 2.2 预览抛出错误

java - 安卓工作室错误 : Could not create the Java Virtual Machine

android - Android 中使用 Canvas 和 SurfaceView 时的 Thread 或 Runnable

token "int"上的 Android R.java 语法错误,此 token 后应为 VariableDeclaratorId

android - com.android.dex.DexException : Multiple dex files define