public class Test extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
Question question=new Question();
getQuestionNo("nik",question);
Toast.makeText(Test.this, question.getQue(), Toast.LENGTH_LONG).show();
}
void getQuestionNo(String email, final Question question)
{
String urlQueNo = PageConfig.QUIZ_QUESTIONNO + email;
StringRequest stringRequest = new StringRequest(urlQueNo, new Response.Listener<String>()
{
@Override
public void onResponse(String response)
{
question.setQue(response);
}
}, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Toast.makeText(Test.this, "error on response1", Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
}
public class Question
{
private String que="hi";
public String getQue()
{
return que;
}
public void setQue(String que)
{
this.que = que;
}
}
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
Question question=new Question();
getQuestionNo("nik",question);
Toast.makeText(Test.this, question.getQue(), Toast.LENGTH_LONG).show();
}
void getQuestionNo(String email, final Question question)
{
String urlQueNo = PageConfig.QUIZ_QUESTIONNO + email;
StringRequest stringRequest = new StringRequest(urlQueNo, new Response.Listener<String>()
{
@Override
public void onResponse(String response)
{
question.setQue(response);
}
}, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Toast.makeText(Test.this, "error on response1", Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
}
public class Question
{
private String que="hi";
public String getQue()
{
return que;
}
public void setQue(String que)
{
this.que = que;
}
}
from Android Forums at AndroidCentral.com - Ask a Question //forums.androidcentral.com/showthread.php?t=765680&goto=newpost
via IFTTT
Aucun commentaire:
Enregistrer un commentaire