我收到了像
这样的网络服务的回复<response>*null 41 23085A49 Madhu 919703473353 1234#</response>.
我想将我的姓名和手机号码显示在我创建的两个编辑文本字段中。你能告诉我如何更新这些字段吗?
答案 0 :(得分:2)
类似的东西:
String args[] = your_webserver_response_as_a_string.split("\\s"); //split on whitespace characters
((EditText)findViewById(R.id.youredittext1)).setText(args[3]);
((EditText)findViewById(R.id.youredittext2)).setText(args[4]);
答案 1 :(得分:1)
首先,您需要从正在使用的Web Service获得正确的响应。 例如,您需要获得XML或JSON等标准数据格式。 在获得类似的标准化响应后,您可以使用XML或JSON Parser在应用程序中解析该响应,并以您喜欢的方式使用它。
答案 2 :(得分:0)
格式似乎是“value1 value2 value3 name number value5”。
string = string.subString(0,string.lastIndexof(" "));
number = String subString(string.lastIndexof(" "));
string = string.subString(0,string.lastIndexof(" "));
name = String subString(string.lastIndexof(" "));
答案 3 :(得分:0)
我建议实施JSON。它易于实现,并且协议非常简单。 使用字符串拆分器是可能的,但它可能会变得很乱。