简体   繁体   English

启用和禁用 TextView 的可编辑模式

[英]enable and disable TextView's editable mode

I'm creating an spread sheet app.我正在创建一个电子表格应用程序。 I use a lot of textView in a table layout as the cells of the spread sheet.我在表格布局中使用了很多 textView 作为电子表格的单元格。 I want as the user double tap on a cell(TextView), the cell become editable (just like an editText).我希望当用户双击单元格(TextView)时,单元格变得可编辑(就像 editText 一样)。 also, I need to disable the cell's edit mode after the user tap on another cell.此外,我需要在用户点击另一个单元格后禁用单元格的编辑模式。 I tried these methods but nothing happened.我尝试了这些方法,但什么也没发生。

private void enableEditMode(TextView cell) {
       cell.setFocusable(true);
       cell.setEnabled(true);
       cell.setClickable(true);
       cell.setFocusableInTouchMode(true);
       cell.setCursorVisible(true);
    }

    private void disableEditMode(TextView cell) {
       cell.setFocusable(false);
       cell.setEnabled(false);
       cell.setClickable(false);
       cell.setFocusableInTouchMode(false);
       cell.setCursorVisible(false);
    }

It's easier to make EditText uneditable.使 EditText 不可编辑更容易。

private void enableEditMode(EditText cell) {
       cell.setFocusable(true);
    }

    private void disableEditMode(EditText cell) {
       cell.setFocusable(false);
    }

should work应该管用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以编程方式启用/禁用沉浸模式 - Programmatically enable/disable Immersive Mode Android Wear - 以编程方式启用/禁用环境模式 - Android Wear - Enable / Disable Ambient mode Programmatically 在 Spring 中为 GraphQL (WebMvc) 启用或禁用异步模式 - Enable or disable async mode in Spring for GraphQL (WebMvc) 如何启用BottomNavigationView的移位模式 - How to enable BottomNavigationView's shifting mode 在微调器选择上启用/禁用RelativeLayout视图 - Enable/Disable RelativeLayout view(s) on Spinner select 在 Spring 中以编程方式启用和禁用某些 @RabbitListener 吗? - Programmatically enable and disable certain @RabbitListener's in Spring? 如何在 Android 上以编程方式启用/禁用热点或网络共享模式? - How do I enable/disable hotspot or tethering mode programmatically on Android? 如何根据另一个 TextView 的内容有条件地启用一个 TextView? - How do I conditionally enable a TextView based on another TextView's contents? 如何使textview的一部分可编辑 - how to make a part of textview editable 如何仅在用户输入某个组件时禁用自定义快捷键,并在焦点不在 java 中的可编辑组件上时再次启用它? - How to disable custom Shortkeys only when user is typing in some component and enable it again when focus is not on editable component in java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM