1. Are you ready for the Galaxy S20? Here is everything we know so far!

Accessing Toolbar in fragment - Marshmallow

Discussion in 'Android Development' started by Talha Hasan Zia, Feb 10, 2016.

  1. Talha Hasan Zia

    Thread Starter

    I want to access toolbar to get text from EditText child of toolbar. I cannot directly access it, so i tried to get toolbar first.

    I have tried several codes nothing is giving me toolbar.

    #1
    Toolbar toolbar =(Toolbar) getActivity().findViewById(R.id.toolbar);


    #2
    AppCompatActivity act =(AppCompatActivity) getActivity();
    if(act.getSupportActionBar()!=null){
    Toolbar toolbar =(Toolbar) act.getSupportActionBar().getCustomView();
    }
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...