fragment - searchfragment is adding to back stack multiple times when i search using actionbar searchview android -
I am using action-bar search-view. Whenever a search is done, I am making a piece, but my problem is that whenever a new search is done, it is also adding backstacks.
Code:
Private Wide Handelent (intent intent) {if (Intent.ACTION_SEARCH.equals (getIntent (). GetAction ())) {QueryString = getIntent () GetStringExtra (SearchManager.QUERY); GetString ("videourl", getResources (). GetString (R.string.serviceurl) + "/ Gateres / + + ((Global Class) getApplicationContext (). GetShared () GetString (" StationID "," Null ") + "/" + QueryString); Bundle ("app", true); Bundle.putString ("xmlroles", session.getUserDetails (). Get (SessionManager.KEY_NAME) .get (1)); bundle.putstring ( "ChannelID", "Empty"); SearchRecentSuggestions Suggestions = New Search Revision Offer (This, MySuggestionProvider.AUTHORITY, MySuggestionProvider.MODE); Suggestions.saveRecentQuery (Query String, blank); Piece Transaction Feet = getFragmentManager (). BeginTransaction (); Searchfragment serving = new searchfraagme (); Searchfragment.setArguments; Ft.replace (R.id.content_frame, searchfragment); ft.setTransition (FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack (zero); ft.commit (); mDrawerToggle.setDrawerIndicatorEnabled ( Wrong); getActionBar () setDisplayHomeAsUpEnabled (true). ((GloabalClass) getApplicationContext ()) setSearch_tab_selection (0). }}
If I have already been added, then how can I create a piece backstack?
try it
fragment manager fragMan = getFragmentManager (); Piece newFragment = faucet; String fragTag = "yourTag"; NewFragment = fragMan.findFragmentByTag (fragTag); If (new alignment == zero) newFragment = new SearchFragment (); Other ((Search Fraagment) New Fragment). Public method (logic); Piece transaction transaction = fragMan.beginTransaction (); Transaction.replace (R.id.main_fragment, newFragment, fragTag); Transaction.addToBackStack (zero); Transaction.commit ();
Instead of adding new pieces, this code adds the same tag to the existing tags.
Comments
Post a Comment