Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The issue is due to the way the fragment lifecycle works. In your onCreateView implementation, you make reference to the fragment's activity when creating the adapter. The problem is that the activity isn't made available to the fragment until onActivityCreated is called.</p> <p>If you look at the <a href="http://developer.android.com/guide/components/fragments.html" rel="nofollow">fragment lifecycle as described here</a> you can see that onCreateView is followed by a call into onActivityCreated.</p> <p>Try moving some code from onCreateView into onActivityCreated:</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.servers, null); FavoritesListView = (ListView) v.findViewById(R.id.serverlistview); return v; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); FavoritesAdapter = new ServerAdapter(this.getSherlockActivity(), R.layout.servers, DataHandler.getUserFavoriteServersFromLocal()); FavoritesListView.setAdapter(FavoritesAdapter); } </code></pre> <p>Additionally, you appear to be using the wrong variable in your adapter's getView() code. You test if Row==null (which means convertView is also null) and then assign Row to be the value of the newly inflated view. However, you then attempt to find a subview from the convertView, which is still null.</p> <p>Try editing your adapter's getView() method as below:</p> <pre><code> @Override public View getView(int position, View convertView, ViewGroup parent) { View Row = convertView; ViewHolder Holder = null; Server server = Data.get(position); if(Row == null) { LayoutInflater inflater = ((Activity)Context).getLayoutInflater(); Row = inflater.inflate(ResourceId, parent, false); Holder = new ViewHolder(); //Holder.Hostname = (TextView)convertView.findViewById(R.id.hostname); //Holder.Address = (TextView)convertView.findViewById(R.id.address); //Holder.Players = (TextView)convertView.findViewById(R.id.players); //Holder.Photo = (ImageView) convertView.findViewById(R.id.imageView1); Holder.Hostname = (TextView)Row.findViewById(R.id.hostname); Holder.Address = (TextView)Row.findViewById(R.id.address); Holder.Players = (TextView)Row.findViewById(R.id.players); Holder.Photo = (ImageView)Row.findViewById(R.id.imageView1); Row.setTag(Holder); } //etc } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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