I have a relative layout and i am adding fragment in that relative layout. Like this
HomeFragment mHomeFragment = new HomeFragment();
FragmentMana
If you want to get the tag of a fragment you can use the getTag() method. This probably isn't going to be the nicest way to achieve what you are looking to do.
http://developer.android.com/reference/android/app/Fragment.html#getTag()
If you have several fragments and you will change them around, consider using an adapter.
Fragment fragment = getFragmentManager().findFragmentById(R.id.order_container);
String tag = (String) fragment.getTag();
You can use findFragmentById
in FragmentManager
getFragmentManager().findFragmentById(R.id.order_container)
getSupportFragmentManager().findFragmentById(R.id.container).getClass().getName();
You want the name?? You can get your fragment using the ID and doing:
fragment.getClass().getName();
is it what you want? Or you can use:
fragment.getTag();
it's returns the tag name of the fragment, if specified.
you can retrieve a Fragment by tag through
Fragment fragment = getFragmentManager().findFragmentByTag("yourstringtag");
then you can check if your fragment is instace of HomeFragment
if (fragment instanceof HomeFragment) {
}