I know this question is asked before here. But there was no solution found.
What I want is to have Next,Previous and Done buttons above the keyboard ( I know its mimicking iphone keyboard,but I m helpless its requirement ).
Like this :
Now what I have tried is ::
So,I took three buttons in one layout and assigned property android:alignParentBottom="true"
and in manifest add android:windowSoftInputMode="adjustResize"
.
Which look like this ::
And What I did to move to and from using "next" "previous button is :
int next=1,prev=1;
public boolean onTouch(View arg0, MotionEvent arg1){
prev=next=1;
return false;
}
});
edUserName.setOnTouchListener(new View.OnTouchListener(){
public boolean onTouch(View arg0, MotionEvent arg1){
prev=next=2;
return false;
}
});
edCity.setOnTouchListener(new View.OnTouchListener(){
public boolean onTouch(View arg0, MotionEvent arg1){
prev=next=3;
return false;
}
});
btnNext.setOnClickListener(new View.OnClickListener(){
public void onClick(View arg0) {
if(next==1){
next++;
prev++;
edUserName.requestFocus();
}else if(next==2){
next++;
prev++;
edCity.requestFocus();
}
}
});
btnPrevious.setOnClickListener(new View.OnClickListener(){
public void onClick(View arg0) {
if(prev==2){
prev--;
next--;
edName.requestFocus();
}else if(prev==3){
prev--;
next--;
edUserName.requestFocus();
}
}
});
This allows me to move to and fro using next and previous buttons.
Now problems ::
I know its little dirty. Please guide if any better way to move to and fro using next and previous buttons.
I want to show buttons only when keyboard is visible otherwise hide them. How can I do this.?
"Done" Button, i need to hide keyboard it its showing, for which i tried this, But, its not working sometimes. :
InputMethodManager imm = (InputMethodManager)getSystemService
(Context.INPUT_METHOD_SERVICE);
if(imm != null){
imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
How to hide the suggestions.
Please help me in this.
Thanks.