Note that there are some explanatory texts on larger screens.

plurals
  1. POfragments and onConfigurationChanged
    primarykey
    data
    text
    <p>I'm trying to do something I do with activities, but within a fragment. What I do is using activities:</p> <p>First stop the activity restarts when rotating the device <code>android:configChanges="keyboardHidden|orientation|screenSize"</code></p> <p>in my activity add:</p> <pre><code>@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setContentView(R.layout.main); } </code></pre> <p>So get the activity does not restart, but reloading the main.xml, to use the layout-land</p> <p>Now I have an activity showing viewpager, which contains three fragments. Everything works properly. Detection of the rotation is in the fragments</p> <pre><code>public class FRG_map_web extends Fragment { @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Log.i("myLogs", "Rotation"); } </code></pre> <p>The problem is that the fragment not use setContentView(R.layout.main); this is the code:</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.frg.myFragment, null); </code></pre> <p>I tried to use:</p> <pre><code>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); </code></pre> <p>and different ways, but always without success I can not inflate properly.</p> <p>Can anyone tell me how I have to do?</p> <p>Thanks in advance, I appreciate the help</p> <p>Regards</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload