I'm trying to do something I do with activities, but within a fragment. What I do is using activities:
First stop the activity restarts when rotating the device
android:configChanges="keyboardHidden|orientation|screenSize"
in my activity add:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.main);
}
So get the activity does not restart, but reloading the main.xml, to use the layout-land
Now I have an activity showing viewpager, which contains three fragments. Everything works properly. Detection of the rotation is in the 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 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 to use:
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 different ways, but always without success I can not inflate properly.
Can anyone tell me how I have to do?
Thanks in advance, I appreciate the help
Regards