Android Spinner Adapter Setting to spinner

android, spinner

Solution

you are passing `this` in the following piece of code,

 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_spinner_item,list);

Not sure in which block this code lies or which class, but ensure that `this` refers to `ActivityName.class` or `the context`

Problem

I'm using eneter framework to process communication in my android application; the problem is when I'm trying to populate a spinner, setting the adapter to the spinner cause an undefined exception Here the code ``` public void populateSpinner(TypedResponseReceivedEventArgs<String> arg1){ List<String> list = new ArrayList<String>(); String listf = arg1.getResponseMessage(); //sendToDebug(listf); StringTokenizer tokenizer = new StringTokenizer(listf,","); while(tokenizer.hasMoreElements()){ list.add((String)tokenizer.nextElement()); } //EditText text = (EditText)findViewById(R.id.number2EditText); //text.setText(list.size()); //text.setText(listf); Spinner forfait = (Spinner)findViewById(R.id.forfaitsSpinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); forfait.setAdapter(adapter); } ```

Original source