Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Almost everything about your code is wrong.</p> <pre><code> Display d = wm.getDefaultDisplay(); if(d.getWidth() &gt; d.getHeight()){ mDetailView = inflater.inflate(R.layout.detail, container, false); }else{ mDetailView = inflater.inflate(R.layout.detail_port, container, false); } gridView = (GridView)mDetailView.findViewById(R.id.grid); </code></pre> <p>Don't do this - The platform has it's own way of loading layouts by using the naming convention. Your code should look like this:</p> <pre><code> mDetailView = inflater.inflate(R.layout.detail, container, false); gridView = (GridView)mDetailView.findViewById(R.id.grid); </code></pre> <p>If you want it to look different in different orientations place two detail.xml files in both <code>layout-port</code> and <code>layout-land</code> and the OS will load the correct one (and deal with deduping all of your resource ids which is likely your problem). Also:</p> <pre><code>DetailFragment detailView = (DetailFragment)getFragmentManager() .findFragmentById(R.id.detailFrame); DetailFragment detailFrag = new DetailFragment(topic_index, subTopicPosition, groupID, groupName); if(detailView==null){ ft.add(R.id.detailFrame, detailFrag); ft.commit(); }else{ ft.replace(R.id.detailFrame, detailFrag); ft.commit(); } </code></pre> <p>You gain access to the Fragment present already. You then create a whole new Fragment. You then check to see if your first Fragment is null before adding the new one anyway? .add() and .replace() are different because add() specifically doesn't remove the previous fragment - replace() will not throw an error however if there isn't a previous fragment to remove so you can use this every time.</p> <pre><code> ft.replace(R.id.detailFrame, new DetailFragment(topic_index, subTopicPosition, groupID, groupName); ft.commit(); </code></pre>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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