Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Take a look at the error message and then take a look at your <code>onCreateView()</code>-method. The error message says you're trying to add a <code>View</code> to a parent, that <em>already has</em> a parent.</p> <p>The reason you're getting the <code>IllegalStateException</code> is because you're trying to add <code>(ViewGroup) container</code> as a child to itself by <code>return</code>-ing <code>container</code> in your <code>onCreateView(...)</code>. Of course <code>container</code> already has a parent, which is why you got the error.</p> <p>Also, the part about the adapter in onCreateView() can throw an error, since your <code>ListFragment</code> doesn't have an adapter yet until you set one. The call to <code>((ImageAdapter) getListAdapter())</code> will (probably) return null, causing <code>.getImageDownloader()</code> to (probably) throw a <code>NullPointerException</code>. Try the following in your <code>Fragment</code>:</p> <pre><code>@Override public void onActivityCreated(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // You should choose what mode you want, // ImageDownloader.Mode.NO_ASYNC_TASK or // ImageDownloader.Mode.CORRECT;... no use in setting it, just // to override it again 1 line later :p ImageDownloader.Mode mode = ImageDownloader.Mode.NO_ASYNC_TASK; mode = ImageDownloader.Mode.CORRECT; ImageAdapter mImageAdapter = new ImageAdapter(); mImageAdapter.setMode(mode); setListAdapter(mImageAdapter); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { v = inflater.inflate(R.layout.imagelist, container, return v; // notice you're returning your inflated View here, // instead of container } </code></pre> <hr> <h2>Update</h2> <p>Also, change your <code>ListActivity</code> to an <code>Activity</code> (or <code>FragmentActivity</code> if you use the support library). Remove the call to <code>setListAdapter(new ImageAdapter());</code> from your <code>Activity</code>, and move the <code>implements RadioGroup.OnCheckedChangeListener</code> to the <code>ListFragment</code>.</p>
 

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