I am trying to do something that I am doing with actions, but inside a fragment. I use actions:
First stop restarting activity when android:configChanges="keyboardHidden|orientation|screenSize" device is spinning android:configChanges="keyboardHidden|orientation|screenSize"
in my activity add:
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setContentView(R.layout.main); }
So, so that the activity does not restart, but main.xml is reloaded, in order to use the layout earth
Now I have an activity showing a viewpager that contains three fragments. Everything is working correctly. Rotation detection occurs in fragments
public class FRG_map_web extends Fragment { @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Log.i("myLogs", "Rotation"); }
The problem is that the fragment does not use setContentView (R.layout.main); this is the code:
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.frg.myFragment, null);
I tried using:
LayoutInflater inflater = inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.frg.myFragment, null); ... LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.frg.myFragment, null); ... LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); view = inflater.inflate(R.layout.frg.myFragment, null); ... LayoutInflater li = LayoutInflater.from(context);
and in different ways, but always without success. I canโt swell right.
Can someone tell me how should I do this?
Thanks in advance for your help.
Hi
android android-fragments layout-inflater
Sergio76
source share