add valor spinner atraves de WebserviceMinha class
public class Cadastro_Usuario extends Activity {
EditText NomeUsu, FotoUsu, NascimentoUsu, SenhaUsu, TelefoneUsu, CelularUsu, EmailUsu, CepUsu, EnderecoUsu, NumeroUsu, ComplementoUsu, BairroUsu, CidadeUsu;
Spinner SexoUsu, EstadoUsu;
private ProgressDialog pDialog;
private List<String> estados = new ArrayList<String>();
private String estado;
private String tag_json_obj = "jobj_req", tag_json_arry = "jarray_req";
private String TAG = Cadastro_Usuario.class.getSimpleName();
@Override
protected void RetornaJSONEstadoonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
showProgressDialogsetContentView(R.layout.activity_cadastro_usuario);
NomeUsu = (EditText) findViewById(R.id.edtnome_usu);
JsonArrayRequest req SexoUsu = new(Spinner) JsonArrayRequestfindViewById(ConstR.URL_JSON_ARRAY_CAD_USUid.spinnersexo_usu);
NascimentoUsu = (EditText) findViewById(R.id.edtdata_usu);
NascimentoUsu.addTextChangedListener(Mask.insert("##/##/####", NascimentoUsu));
SenhaUsu = (EditText) findViewById(R.id.edtsenha_usu);
TelefoneUsu = (EditText) findViewById(R.id.edttelefone_usu);
TelefoneUsu.addTextChangedListener(Mask.insert("(##)####-####", TelefoneUsu));
CelularUsu = (EditText) findViewById(R.id.edtcelular_usu);
CelularUsu.addTextChangedListener(Mask.insert("(##)#####-####", CelularUsu));
EmailUsu = (EditText) findViewById(R.id.edtemail_usu);
CepUsu = (EditText) findViewById(R.id.edtcep_usu);
CepUsu.addTextChangedListener(Mask.insert("##.###-####", CepUsu));
EnderecoUsu = (EditText) findViewById(R.id.edtendereco_usu);
NumeroUsu = (EditText) findViewById(R.id.edtnumero_usu);
ComplementoUsu = (EditText) findViewById(R.id.edtcomplemento_usu);
BairroUsu = (EditText) findViewById(R.id.edtbairro_usu);
CidadeUsu = (EditText) findViewById(R.id.edtcidade_usu);
EstadoUsu = (Spinner) findViewById(R.id.spinnerestado_usu);
pDialog = new ResponseProgressDialog(this);
pDialog.Listener<JSONArray>setMessage("Loading...");
pDialog.setCancelable(false);
RetornaJSONEstado();
}
private void RetornaJSONEstado() {
showProgressDialog();
JsonArrayRequest req = new JsonArrayRequest(Const.URL_JSON_ARRAY_CAD_USU,
@Override new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
hideProgressDialog();
int aJsonint = 0;
String aJsonString;
String aJsonString; // Recupera seu adapter
ArrayAdapter<String> adp = (ArrayAdapter<String>) EstadoUsu.getAdapter();
// Desabilito a notificao trypor {enquanto, ate terminar de adicionar tudo
adp.setNotifyOnChange(false);
try {
JSONArray jsonarray = response;
JSONObject jsonobj;
for (int i=0; i<jsonarray.length(); i++){
jsonobj = jsonarray.getJSONObject(i);
aJsonString = jsonobj.getString("sigla");
aJsonint = jsonobj.getInt("id");
System.out.println("ID " + aJsonint + " sigla " + aJsonString);
// Voce pode adicionar aqui, mas nao eh recomendado
//estados.add(aJsonString);
}
// Adiciono direto no ArrayAdapter
} catch (JSONException e adp.add(aJsonString);
{ }
// Habilitar novamente a enotificacao
adp.printStackTracesetNotifyOnChange(true);
// Notifica o Spinner de que houve mudanca no modelo
adp.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
System.out.println("Deu ERROR PQP");
hideProgressDialog();
msgerro();
finish();
}
}
);
// Adding request to request queue
AppController.getInstance().addToRequestQueue(req,
tag_json_arry);
// Cancelling request
// ApplicationController.getInstance().getRequestQueue().cancelAll(tag_json_arry);
}
private void msgerro(){
Toast.makeText(this, "Verifique sua conexao com internet e tente novamente", Toast.LENGTH_LONG).show();
}
private void showProgressDialog() {
if (!pDialog.isShowing())
pDialog.show();
}
private void hideProgressDialog() {
if (pDialog.isShowing())
pDialog.hide();
}
}
Fiz a alteração que indicou e esta dando esse erro
09-23 11:59:26.348 2211-2211/spac.com.br.jobbroker W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40a13300)
09-23 11:59:26.398 2211-2211/spac.com.br.jobbroker E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NullPointerException
at spac.com.br.jobbroker.Cadastro.Cadastro_Usuario$1.onResponse(Cadastro_Usuario.java:102)
at spac.com.br.jobbroker.Cadastro.Cadastro_Usuario$1.onResponse(Cadastro_Usuario.java:89)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:65)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)