简体   繁体   中英

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. I want as the user double tap on a cell(TextView), the cell become editable (just like an 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.

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

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

should work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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