Android : Layout inflating again and again on Searching

on Wednesday, August 6, 2014


I have one Fragment DefaultMapFragment which extends Fragment where I'm inflating my layout.


This Fragment is inside an Activity ActivityMain.When I do search it seaches in a Activity so layout inflation happens again and again.


Here's my code to describe what I'm doing:



protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

setContentView(R.layout.add_geofence_layout);
Intent mIntent = getIntent();

if(!(mIntent.getAction().equals(Intent.ACTION_SEARCH)))
{
mFragmentManager = getFragmentManager();

mTransaction = mFragmentManager.beginTransaction();

mTransaction.add(R.id.add_layout, new DefaultMapFragment(),"defaultMapFragment").commit();

mGeocoder = new Geocoder(this, Locale.getDefault());
}


handleIntent(getIntent());


}


So I thought it would be enough to check for the condition if i'm searching but then it does not inflate at all and so my map won't display.


What should I do in this case??


0 comments:

Post a Comment