Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid getSystemService inside custom ArrayAdapter
    primarykey
    data
    text
    <p>I was trying to write a custom ArrayAdapter referencing <a href="http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/" rel="noreferrer">here</a> My code is </p> <pre><code>package com.example.AndTest; import java.util.ArrayList; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class CategoryAdapter extends ArrayAdapter&lt;Category&gt; { private ArrayList&lt;Category&gt; items; public CategoryAdapter(Context context, int textViewResourceId, ArrayList&lt;Category&gt; items) { super(context, textViewResourceId, items); this.items = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.list, null); } Category c = items.get(position); if (c != null) { TextView itemId = (TextView) v.findViewById(R.id.itemid); TextView itemLabel = (TextView) v.findViewById(R.id.itemlabel); if (itemId != null) { itemId.setText("Name: " + c.getId()); } if (itemLabel != null) { itemLabel.setText("Status: " + c.getTitle()); } } return v; } } </code></pre> <p>But I'm getting error message on the line <code>LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);</code></p> <p><code>The method getSystemService(String) is undefined for the type CategoryAdapter</code></p> <p>Am i missing something..</p> <pre><code>public class Category implements Parcelable { .... } </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.
 

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