I have an edit text and i want to know if the cursor has moved to the next line or not, if it has moved to next line i want to call a new function. how can i do this? Is there a way or a function from which i can know that the cursor has moved to the next line?
PS: I am using a text watcher to implement Upper case and lower case functionality
scene.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int i, int j, int k) {
if(flag!=0)
{
flag=1;
strcheck = s.toString().charAt(s.length()-1);
int line = getCurrentCursorLine(scene);
lineno = line;
if(strcheck=='\n' && ib1==true){
ib22(scene, lineno);
} else if(strcheck=='\n' && ib2==true){
ib22(scene, lineno);
} else if(strcheck=='\n' && ib3==true){
ib55(scene, lineno);
} else if(strcheck=='\n' && ib4==true){
ib55(scene, lineno);
} else if(strcheck=='\n' && ib5==true){
ib33(scene, lineno);
} else if(strcheck=='\n' && ib6==true){
ib11(scene, lineno);
} else if(strcheck=='\n' && ib7==true){
ib22(scene, lineno);
} else if(strcheck=='\n' && ib1==false && ib2==false && ib3==false && ib4==false && ib5==false && ib6==false && ib7==false){
ib22(scene, lineno);
}
//int start = scene.getLayout().getLineStart(lineno);
//int end = scene.getLayout().getLineEnd(lineno);
//String previous = (start<1 && lineno==0)?"":scene.getText().toString().substring(0, start);
if (nowUpper){
flag = 0;
strcheck = Character.toUpperCase(strcheck);
scene.setText(scene.getText().toString().substring(0,scene.length()-1) + strcheck);
//scene.setText(previous + scene.getText().toString().substring(start, end).toUpperCase());
scene.setSelection(scene.getText().length());
}
else if (nowLower){
strcheck = Character.toLowerCase(strcheck);
}
}
else{
flag=1;
}
}
public void afterTextChanged(Editable editable) {
}
public void beforeTextChanged(CharSequence cs, int i, int j, int k) {
}
});