Increase a char value by one

前端 未结 6 2168
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-18 17:24

I have an app with an EditText and a button named \"forward\". All I want is just when I type \"a\" in the EditText and click the button, the word \"b\

6条回答
  •  [愿得一人]
    2021-02-18 18:02

    You need to convert the text value (character) to the ascii value, then increase it, not just the text.

    value = edt.getText().toString();
    int ascii = (int)value;
    edt.setText(Character.toString ((char) ascii+1));
    

提交回复
热议问题