I have this app on iphone and I want to make it for android,on iphone when start edit text in a EditText a tooltip with a message is showing in the top of display,i want to make it work for android too,but i didn't find anything that help,here is a link with iphone printscreen
http://www.codemyworld.com/edi/Android/IMG_0022.PNG
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
//your code here
//showtooltip();
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
}
There isin't a hovering tooltip concept in Android. You can do either of the 2 things:
LongClickListener
for your EditText
which will show a toast when user long presses on it. Something like this:
View view = (View)findViewById(R.id.your_view);
view.setOnLongClickListener(new OnLongClickListener() {
@Override
public void onLongClick(View v) {
Toast toast = Toast.makeText(this, "Show hint here", Toast.LENGTH_SHORT);
}
});
OR
Show Hint in the EditText to let users know what do they need to type in.
<EditText
android:hint="Your tip here" />
This can be done using OnFocusChangeListener on EditText
The idea is that you will create tool tip layout and will change its visibility on Focus change
You can create tip layout by either top of normal layout using FrameLayout or by just adding tool tip layout at top of your layout. In both these cases visibility will be gone.
Then use OnFocusChangeListener to show or hide tool tip
edittxt.setOnFocusChangeListener(new OnFocusChangeListener()
{
@Override
public void onFocusChange(View v, boolean hasFocus)
{
if (hasFocus == true)
{
// Show tool tip
}else{
// Hide tool tip
}
}
});
You can also enhance this with different listeners like OnKeyListener
Just to improve my answer
you can also use TextWatcher Class of Android which facilitates us to react on Text Change.
Please refer following for use of TextWatcher in your example
TextWatcher textWatcher = new TextWatcher()
{
@Override
public void onTextChanged(CharSequence s , int start,int before,int count){
}
@Override
public void afterTextChanged(Editable s){
}
@Override
public void beforeTextChanged(CharSequence s, int start,int count, int after){
}
};
Then use it as
edittext.addTextChangedListener(textWatcher);
You can use this:
TooltipCompat.setTooltipText(editText, editText.getText())