簡體   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