简体   繁体   中英

Navigation Drawer app behaivour when open fragments

Im working with a Android app that uses Navigation Drawer. This app use the template provided with Eclipse ADT (when you select the navigation drawer template).

I dont understand the behaivour of the navigation drawer very well.

My main requeriment is make a "search" option, I have on the Navigation Drawer a EditText to get the query string from the user. I want that I press search button and open my SearchFragment getting the search query.

I know that I can make this:

    Bundle args = new Bundle();
    args.putString("searchQuery",searchQuery);
    fragment.setArguments(args);

And this for getting:

    getArguments().getString("searchQuery");

But I have the next:

  • MainActivity
  • NavigationDrawerFragment
  • SearchFragment
  • OtherFragments.. (I think this arent relevant in the question)

I dont understand where I can make this steps.

More data: I have in the navigation drawer class the EditText with the setOnEditorActionListener for the search press.

Any info that I can add I will be add. Sorry my english

Thanks for the help

Navigation drawer is basically a component that show 2 pane in the way that one is the main pane (usually fragment) that is used to show content and the other one is usually a listview that is just used to choose which fragment to show in main pane so if you want to switch between 2 different layouts you have to create 2 different fragments and then you can add or replace these fragments based on listview's selected item. You may refer to below link for complete code http://developer.android.com/training/implementing-navigation/nav-drawer.html

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM