2
I have a screen where it has a Gridview
and a ImageButton
.
Well, by clicking on that ImageButton
open a PopUp
containing two spinner
and a ImageButton
.
Those spinners
are populated through a web service that is called after the user logs in, so far so good.
When I select the information in both spinners
and I click on button
I can’t recover the values (description or id) I populated with my adapter
where, if I use the same code outside a Popup, I can retrieve the information but when I use it in a popup.
Follow my Adapter code for my spinner
package br.com.projeto.adapter;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.com.projeto.entidade.DadosFiliais;
import br.com.projeto.entidade.DadosPortifolio;
import br.com.projeto.osportifolio.R;
public class SpinnerAdapter extends BaseAdapter {
private Context context;
ArrayList<DadosFiliais> data = new ArrayList<DadosFiliais>();
public SpinnerAdapter(Context context,ArrayList<DadosFiliais> data) {
this.context = context;
this.data = data;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
DadosFiliais datas = new DadosFiliais();
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(android.R.layout.simple_list_item_1, null);
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
text1.setText(data.get(position).getDsFilial());
return view;
}
@Override
public int getCount() {
return 32;
}
@Override
public Object getItem(int position) {
return "TextView";
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.row_spinner, null);
TextView text1 = (TextView) view.findViewById(R.row_s.dados_spinner);
TextView text2 = (TextView) view.findViewById(R.row_s.dados_spinner_2);
text1.setText(data.get(position).getDsFilial());
text2.setText(data.get(position).getCdFilial());
return view;
}
}
Code used to pick up spinner values
String localidadeStr = txtLocalidade.getText().toString();
String movimentoStr = txtMovimento.getText().toString();
localidade = Integer.parseInt(localidadeStr);
movimento = Integer.parseInt(movimentoStr);
instead of bringing the value it recovers the value "Textview"