java - 按钮 OnClickListener 给出 ViewPostImeInputStage ACTION_DOWN 错误
问题描述
我正在尝试创建一个简单的 Android 程序。我创建了一个活动并仅添加了一个按钮,我在该按钮上设置了一个 OnclickListener 以在日志中打印“Hello World”,这是一项简单的任务。但是每当我运行应用程序时,每次单击按钮时,都会收到错误“ViewPostImeInputStage ACTION_DOWN”。
我尝试将我的布局放在 FragmentLayout 中,或者构建另一个项目,或者更新 Android Studio,所有这些都是这里推荐的解决方案。这些都没有奏效,我仍然得到同样可怕的“ViewPostImeInputStage ACTION_DOWN”。
这是我的java文件
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button= findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.print("Hello World");
}
});
}
和我的 xml 文件
`<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="243dp"
android:text="Button" />
</RelativeLayout></FrameLayout>
如果有人可以帮我解决这个问题,将不胜感激。OnclickListener 对我来说一直很顺利,但由于某种原因,现在我无法完成最基本的任务。帮助!
解决方案
Germain Edouard 尝试在
推荐阅读
- javascript - 无法获取控制台日志 - d3 JavaScript
- java - SpringBoot中实体之间的ManyToOne关系给出SQL错误:1048
- ruby-on-rails - CanCanCan 抛出 ActiveModel::UnknownAttributeError 设置不存在的属性
- python - 在熊猫数据框的特定列上使用 t.test_ind
- linux - 动态重命名 HDFS 目录中的多个文件
- asp.net - 如何为 MVC4 开发一个双重列表框 - 可以从左侧区域选择项目并在右侧区域中选择项目
- typescript - 如何让 Vue 实例之外的函数具有正确的 `this` 上下文?
- php - whereJsonContains Laravel 5.6 不工作?
- python - 减少大协方差矩阵的计算时间和要求
- jekyll - Jekyll 在 main.scss 中找不到包含的文件或文件有错误