我有四个单选按钮,我想为每个按钮设置一个文本,我从服务器获取数据并将数据设置为这些按钮:
protected String[] doInBackground(String... params) {
HttpClient client = new DefaultHttpClient();
website = new URI(
"http://10.0.2.2:8080/LocalizedBasedComptitionServer/SendQuestion");
HttpPost request = new HttpPost();
request.setURI(website);
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
results[0] = response.getFirstHeader("Info").toString();
results[1] = response.getFirstHeader("Question").toString();
results[2] = response.getFirstHeader("Choice1").toString();
results[3] = response.getFirstHeader("Choice2").toString();
results[4] = response.getFirstHeader("Choice3").toString();
results[5] = response.getFirstHeader("Choice4").toString();
results[6] = response.getFirstHeader("Hint1").toString();
results[7] = response.getFirstHeader("Hint2").toString();
}
protected void onPostExecute(String[] results) {
super.onPostExecute(results);
question.setText(results[1]);
choice1.setText(results[2]);
choice2.setText(results[3]);
choice3.setText(results[4]);
choice4.setText(results[5]);
firstHint.setText(results[6]);
secondHint.setText(results[7]);
// rightChoice = Integer.parseInt(results[8]);
}
但我的问题是,如果我发送罗马,米兰,意大利,爱给客户,打印到无线电接口的数据是选择1:罗马选择2:米兰,选择3:意大利,选择4:爱 我不想打印那个choice1,choice2,choice3,choice4 我做错了什么,谢谢
答案 0 :(得分:2)
尝试response.getFirstHeader("xxx").getValue()