android EditText设置不可编辑
时间: 2023-07-22 10:04:00 浏览: 113
Android EditText不可编辑,可以通过以下两种方式实现:
1.设置EditText的属性为android:editable="false"或android:inputType="none",这样就可以禁止用户对EditText进行编辑。
2.在Java代码中通过setFocusable(false)和setFocusableInTouchMode(false)方法来禁止EditText获取焦点,从而实现不可编辑的效果。
相关问题
edittext设置不可编辑
你可以通过以下代码将EditText设置为不可编辑:
```
EditText editText = findViewById(R.id.editText);
editText.setFocusable(false);
editText.setFocusableInTouchMode(false);
```
或者在xml文件中添加以下属性:
```
android:editable="false"
android:focusable="false"
android:focusableInTouchMode="false"
```
这样就可以禁止用户编辑EditText了。
android edittext不可编辑
Android EditText不可编辑,可以通过以下两种方式实现:
1.设置EditText的属性为android:editable="false"或android:inputType="none",这样就可以禁止用户对EditText进行编辑。
2.在Java代码中通过setFocusable(false)和setFocusableInTouchMode(false)方法来禁止EditText获取焦点,从而实现不可编辑的效果。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)