I am having a problem with the on key listener, which i have completely explained here Unable to get line number on press of ENTER
Now if i am using a textwatcher to implement certain functionalities on my edittext, i need the line number everytime when my cursor moves to the next line. i want to know when the ENTER key is pressed, how can i do that
here is the code of textwatcher
scene.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//here is your code
strcheck = s.toString().substring((s.length()-1),s.length());
if (nowUpper)
strcheck = strcheck.toUpperCase();
else if (nowLower)
strcheck = strcheck.toLowerCase();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
if (nowUpper){
if(ix==1)
{
if(strcheck=="\n")
strcheck="a";
Log.v(strcheck, strcheck);
ix=0;
scene.setText(scene.getText().toString().substring(0,scene.length()-1) + strcheck);
scene.setSelection(scene.getText().length());
}
else
{
ix=1;
}
// TODO Auto-generated method stub
}
}
});