Configure Spinner Adapter for Android

I use the enter framework to handle communications in an Android app; the problem is that I am trying to fill the counter by setting the adapter in spinner, throwing an undefined exception

Here is 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); } 
+6
source share
2 answers

you go through this in the following code snippet,

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

Not sure which block this code is in or which class, but make sure this refers to ActivityName.class or the context

+21
source

Most likely because you are using an ArrayAdapter , not a SpinnerAdapter . ArrayAdapter is an indirect executor of the SpinnerAdapter interface, not one that claims to implement the interface. Check out the undefined exception. You are probably saying that setAdapter(ArrayAdapter) not defined for Spinner .

0
source

All Articles