按钮OnClickListener产生ViewPostImeInputStage ACTION_DOWN错误

时间:2019-05-22 11:00:18

标签: java android button onclicklistener

我正在尝试创建一个简单的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一直为我工作得很顺利,但是由于某些原因,现在我无法完成最基本的任务。救命!

1 个答案:

答案 0 :(得分:0)

Germain Edouard尝试删除“

相关问题