繁体   English   中英

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

[英]enable and disable TextView's editable mode

我正在创建一个电子表格应用程序。 我在表格布局中使用了很多 textView 作为电子表格的单元格。 我希望当用户双击单元格(TextView)时,单元格变得可编辑(就像 editText 一样)。 此外,我需要在用户点击另一个单元格后禁用单元格的编辑模式。 我尝试了这些方法,但什么也没发生。

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);
    }

使 EditText 不可编辑更容易。

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

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

应该管用

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM