我有一个微调器,我正在动态加载微调器,其中包含我正在执行的消息,如下所示
protected List<Message> messages = null;
ArrayAdapter <Message> arrayadapter = new ArrayAdapter<Message>( activity,android.R.layout.simple_spinner_item,messages);
spinner1.setAdapter(arrayadapter);
我收到如下消息
public List<Message> getMessages(String type) throws Exception{
HttpClient client = new HttpClient();
GetMethod get = null;
Message message = null;
List<Message> messages = new ArrayList<Message>();
try {
get = new GetMethod("http://" + Constants.CLOUD_SERVER_URL + Constants.getMessages + "/"+type);
int statusCode = client.executeMethod(get);
if(statusCode == 200){
Log.d(TAG, "Successfully posted the comments");
Utils utils = new Utils();
Document doc = utils.formatInputStream(get.getResponseBodyAsStream());
NodeList listMessages = doc.getElementsByTagName("message");
int totalMessage = listMessages.getLength();
for (int s = 0; s < totalMessage; s++) {
Node messageNode = listMessages.item(s);
if (messageNode.getNodeType() == Node.ELEMENT_NODE) {
Element messageElement = (Element) messageNode;
message = new Message();
message.setId(utils.getTagValue(messageElement, "id"));
message.setMessage(utils.getTagValue(messageElement, "question"));
messages.add(message);
Log.d(TAG, "Id - " + message.getId() + " Message - " + message.getMessage());
}
}
}else{
Log.d(TAG, "Either server has problem or not reachable at this time");
throw new Exception("Server Issue Status code return by server is " + statusCode);
}
Log.d(TAG, "recommend ----------> Step 15");
Log.d(TAG, "recommend ----------> Step 20");
}finally{
get.releaseConnection();
get = null;
}
return messages;
}
我的问题是我在微调器中获取消息的 id 而不是消息文本如何将该消息转换为字符串并将其传递给适配器或最终我在微调器中获取文本的任何其他方式。