0

I'm new to Android programming, and I'm studying how to create a personal Adapter for a ListView and on tutorial in the new Adapter's constructor has this lines:

public class RecipeAdapter extends BaseAdapter {

    private Context mContext;
    private LayoutInflater mInflater;
    private ArrayList<Recipe> mDataSource;

    public RecipeAdapter(Context context, ArrayList<Recipe> items) {
        mContext = context;
        mDataSource = items;
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

}

The tutorial doesn't describe what is exactly Context and what this line does: mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); and I dont understand it.

Can you describe them?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
alessi
  • 1

1 Answers1

0

Here you can find a tutorial about extending from the BaseAdapter class: http://abhiandroid.com/ui/baseadapter-tutorial-example.html

EDIT

context is the "context" the active activity "lives" in. From this context you get the inflater. The inflater is used to inflate xml layouts you created for your listview.

Additional information about context Related SO question What is 'Context' on Android?

Additional inrormtion about the layoutinflater Related SO question What does LayoutInflater in Android do?

Community
  • 1
  • 1
S. Dragomir
  • 318
  • 2
  • 11
  • This was posted as an answer, but it does not attempt to answer the question. It should possibly be an edit, a comment, another question, or deleted altogether. – Phantômaxx Oct 08 '16 at 20:56