当我知道字符在其中的位置(或键)时,我只想提取CharSequence中的确切字符!
For eg: In the CharSequence "HELLO" I want to Extract the letter in the position 2 which is "E" in this case
. 我怎样才能做到这一点?
更具体地说: 我正在构建一个 Android 应用程序,我在其中使用 TextWatcher 获取人们在 TextEdit 字段中输入的文本,如下所示。
EditText KeyLogEditText = (EditText) findViewById(R.id.editTextforKeyLog);
KeyLogEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Here is where I need help!!
// I have the "start" and "before" keys I have the position of the character inserted
// I need to obtain the EXACT character from the CharSequence "s", How do I Do that?
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
我的问题也在代码中进行了注释。
感谢任何人都可以提供的任何帮助。阿迪特