Android spinner mostrando reference de object em vez de string

Ok, então estou tendo um problema com o meu spinner. Está sendo preenchido com dados retirados de um service web. A questão que estou tendo é que quando o spinner não é clicado em vez de mostrair a string paira o primeiro item no spinner, está mostrando uma reference de object paira ele.

Eu examinei uma questão relacionada, mas ainda não consegui view o que estou faltando, é tão simples quanto falta uma reference toString?

  • Precisa lidair com exception não detectada e enviair file de log
  • Android Salve imagens em SQLite ou SDCaird ou memory
  • Gradle Build Android Project "Não foi possível resolview todas as dependencies" erro
  • PreferenceActividade: salve o valor como integer
  • Maircando mensagens SMS como lido / não lido ou excluindo mensagens que não funcionam no KitKat
  • Como desenhair círculo com pairtição no Android?
  • Aqui está o código paira preencher o spinner

    private void buildDrinkDropDown() { List<NameValuePair> apiPairams = new ArrayList<NameValuePair>(1); apiPairams.add(new BasicNameValuePair("call", "drinkList")); bgt = new BackGroundTask(MAP_API_URL, "GET", apiPairams); try { JSONArray drinks = bgt.execute().get(); for (int i = 0; i < drinks.length(); i++) { JSONObject d = drinks.getJSONObject(i); String id = d.getString(TAG_ID_DRINK); String createdAt = d.getString(TAG_CREATED_AT); String updatedAt = d.getString(TAG_UPDATED_AT); String price = d.getString(TAG_PRICE); String name = d.getString(TAG_NAME); drinkList.add(new Drink( createdAt ,id, name, price,updatedAt )); } drinkField = (Spinner) findViewById(R.id.countryField); DrinkAdapter dAdapter = new DrinkAdapter(this, android.R.layout.simple_spinner_item, drinkList); drinkField.setAdapter(dAdapter); drinkField.setOnItemSelectedListener(new OnItemSelectedListener(){ @Oviewride public void onItemSelected(AdapterView<?> pairent, View view, int position, long id) { //Drink selectedDrink = drinkList.get(position); GlobalDrinkSelected = drinkList.get(position).getId().toString(); } @Oviewride public void onNothingSelected(AdapterView<?> pairent) {} }); } catch (JSONException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } 

    Aqui está o código da class de adaptadores

     package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } importa android.widget.TextView; package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return super.getView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } 

    Aqui está o xml paira o layout dropdown_value_id que é usado no adaptador

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/item_value" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LineairLayout> 

    Se precisair de mais informações, basta gritair.

    Qualquer ajuda seria muito procurada

    Editair: Captura de canvas

    Screenshot de spinner

  • Como faço paira colocair uma bairra de busca em uma checkbox de dialog de alerta?
  • Como posso passair um valor de uma página HTML paira outra usando o JavaScript?
  • Verifique se o cairtão SD está disponível ou não programaticamente
  • Como definir a mairgem do ImageView usando o código, não o xml
  • Picasso não está cairregando a image
  • A intenção não foi restaurada corretamente depois que a atividade é morta se os sinalizadores superiores e superiores simples forem fornecidos
  • 4 Solutions collect form web for “Android spinner mostrando reference de object em vez de string”

    Meu pensamento rápido: o método getView () é usado paira representair a linha. Você pode implementair encoding similair como o método getDropDownView no método getView () também.

    Copie o conteúdo do método getDropDownView paira o método getView ()

    Eu não tentei isso, mas eu tinha feito similair em ListView, onde eu fiz encoding semelhante no método getView ().

    Também tentairei replicair isso localmente e publicair se encontrair alguma coisa.

    Eu estava tendo um problema semelhante, no entanto, eu estava usando o ArrayAdapter padrão sem estendê-lo em uma class sepairada. Depois de olhair paira dentro um pouco, achei isso:

    No entanto, o TextView é referenciado, ele será preenchido com o toString () de cada object na matriz. Você pode adicionair lists ou airrays de objects personalizados. Substitua o método toString () de seus objects paira determinair qual text será exibido paira o item na list.

    O ArrayAdapter padrão chamairá .toString () em cada object na matriz que foi passada paira o Adaptador. Se o seu DrinkAdapter não fizer nada além de exibir o nome da bebida, você pode replace o método toString () e terminair

    Adaptador:

     ArrayAdapter<Drink> drinkAdapter = new ArrayAdapter<Drink>(getActivity(), android.R.layout.simple_spinner_dropdown_item, drinks); 

    Objeto de class:

     public Drink { String name; // Constructor, getters, and setters for the object here @Oviewride public String toString() { return getName(); // You can add anything else like maybe getDrinkType() } } } public Drink { String name; // Constructor, getters, and setters for the object here @Oviewride public String toString() { return getName(); // You can add anything else like maybe getDrinkType() } } 

    E você terminou, não precisa fazer uma class sepairada paira o seu DrinkAdapter

    Ok, então resolvi isso fazendo um pouco mais de search e analisando a resposta a esta pergunta. Exemplo de item personalizado do setDropDownViewResource spinner

    Eu extrai o que estava fazendo no getDropDownView e liguei tanto no getView quanto no getDropDownView.

    aqui está o código

     package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } importa android.widget.TextView; package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } { package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } } package com.android.main; import java.util.ArrayList; import android.app.Activity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class DrinkAdapter extends ArrayAdapter<Drink> { private Activity context; ArrayList<Drink> data = null; public DrinkAdapter(Activity context, int resource, ArrayList<Drink> data) { super(context, resource, data); this.context = context; this.data = data; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Ordinairy view in Spinner, we use android.R.layout.simple_spinner_item return initView(position, conviewtView, pairent); } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // This view stairts when we click the spinner. return initView(position, conviewtView, pairent); } private View initView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.dropdown_value_id, pairent, false); } Drink item = data.get(position); String test = item.getName(); Log.d("test ", test); if(item != null) { TextView drinkName = (TextView) row.findViewById(R.id.item_value); if(drinkName != null){ drinkName.setText(item.getName()); Log.d("find me ", drinkName.toString()); } } return row; } } 

    Na sua class, defina Objeto paira mostrair em ListView, você adiciona uma linha de exemplo de código abaixo

     @Oviewride public String toString() { return getComment(); } 

    É uma palavra paira mim.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.