I have EditText in which user type their Account Number. Now what i want that when user stop typing his Account Number in EditText then i want to show that Account Number in ActionBar. How can i achieve this ?
Asked
Active
Viewed 77 times
0
-
http://stackoverflow.com/a/26506858/5471104 – Mohammed Atif Aug 12 '16 at 07:24
-
Possible duplicate of [In android app Toolbar.setTitle method has no effect – application name is shown as title](http://stackoverflow.com/questions/26486730/in-android-app-toolbar-settitle-method-has-no-effect-application-name-is-shown) – Mohammed Atif Aug 12 '16 at 07:24
-
1how do you know its stop typing?want to do on any click or length of string? – Sohail Zahid Aug 12 '16 at 07:26
-
Title Already showing on action bar I want to show these Right side of title. – Aug 12 '16 at 07:28
-
I used "addTextChangedListener" to know user stop typing. – Aug 12 '16 at 07:30
-
And still don't know when user stop typing. – cowboi-peng Aug 12 '16 at 07:40
2 Answers
0
This code may work:
getSupportActionBar().setTitle(editText.getText().toString());
If you want set the title in the right of the action bar, It is recommended to use Toolbar
for you can custom the layout.

L. Swifter
- 3,179
- 28
- 52
-
Thanks L. Swifter. Title Already showing on action bar I want to show these Right side of title. – Aug 12 '16 at 07:28
-
0
Try using a TextWatcher. Something like this:
editText.addTextChangedListener(new TextWathcer(){
void beforeTextChanged(CharSequence s, int start, int count, int after){}
void onTextChanged(CharSequence s, int start, int before, int count){}
void afterTextChanged(Editable s){
getSupportActionBar().setTitle(s.getText().toString());
}
});

MidasLefko
- 4,499
- 1
- 31
- 44