Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android按钮或任何其他不可点击的视图_Android_Button_Click - Fatal编程技术网

Android按钮或任何其他不可点击的视图

Android按钮或任何其他不可点击的视图,android,button,click,Android,Button,Click,我已经挂上了这面旗 getWindow().setFlags(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG, WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); 用于创建锁屏,获得了成功,但无法获得屏幕上显示的按钮的单击侦听事件 我的代码如下 super.onCreate(savedInstanceState); pref = Prefere

我已经挂上了这面旗

getWindow().setFlags(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG,
                    WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
用于创建锁屏,获得了成功,但无法获得屏幕上显示的按钮的单击侦听事件

我的代码如下

    super.onCreate(savedInstanceState);
    pref = PreferenceManager.getDefaultSharedPreferences(this);

    setContentView(R.layout.activity_lockscreen);
findViewById(R.id.btnClear).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(this, "hello", Toast.LENGTH_SHORT).show();
        }
    });