当禁用“编辑文本”时,OnClickListener不起作用

时间:2019-02-14 18:52:52

标签: java android

我的android应用程序中有一个edittext视图。对于免费用户,我要禁用edittext视图,当用户点击它时,我要显示Toast。 我已通过以下代码管理了禁用编辑的功能

text_status1.setEnabled(false);

但是现在我的setOnClickListener也无法正常工作。有人可以在禁用edittext的情况下帮助我使其工作吗?

谢谢

1 个答案:

答案 0 :(得分:3)

以这种方式使用 "devDependencies": { "@vue/test-utils": "^1.0.0-beta.27", "axios": "^0.18", "babel-core": "7.0.0-bridge.0", "babel-jest": "^23.6.0", "bootstrap": "^4.0.0", "cross-env": "^5.1", "jest": "^23.6.0", "jquery": "^3.2", "laravel-mix": "^4.0.7", "lodash": "^4.17.5", "nodemon": "^1.18.9", "popper.js": "^1.12", "resolve-url-loader": "^2.3.1", "sass": "^1.15.2", "sass-loader": "^7.1.0", "vue": "^2.6.2", "vue-jest": "^3.0.2" }, "dependencies": { "@babel/core": "^7.2.2", "babel-loader": "^8.0.5", "bootstrap": "^4.1.3", "bootstrap-vue": "^2.0.0-rc.11", "cross-env": "^5.2.0", "node-sass": "^4.11.0", "nuxt": "^2.4.0", "vue-loader": "^15.6.2" } 代替setEnabled

setFocusable

通过使用setFocusable false,用户可以在视图上执行单击,但无法获得编辑editText所需的焦点