0

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 ?

2 Answers2

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
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