首页 > 解决方案 > 按钮 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 对我来说一直很顺利,但由于某种原因,现在我无法完成最基本的任务。帮助!

标签: javaandroidbuttononclicklistener

解决方案


Germain Edouard 尝试在


推荐阅读