如何从这种Web服务获取数据
这是我的Web服务数据。如何从这种Web服务获取数据
[
{
"msgid": "1",
"title": "Lorem Ipsum is simply text",
"dt": "05-SEP-2012"
},
{
"msgid": "2",
"title": "Lorem Ipsum is simply ",
"dt": "16-NOV-2011"
},
{
"msgid": "3",
"title": "Lorem Ipsum is simply text",
"dt": "13-SEP-2012"
},
{
"msgid": "4",
"title": "Lorem Ipsum is simply text2",
"dt": "26-SEP-2012"
},
{
"msgid": "5",
"title": "Lorem Ipsum is simply text",
"dt": "30-SEP-2012"
},
{
"msgid": "6",
"title": "test message ",
"dt": "12-OCT-2012"
},
{
"msgid": "7",
"title": "test message ",
"dt": "01-OCT-2012"
}
]
如何在Android中使用JSON解析将此数据提取到应用程序? 究竟是什么数据u能帮助我.... PLZ java代码....
公共类Original_list延伸活动{
TextView web;
ArrayList<String> id1,question1 ;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
web = (TextView)findViewById(R.id.web1);
id1 = new ArrayList<String>();
question1= new ArrayList<String>();
try {
JSONArray jary = new JSONArray(readTxt());
for(int i = 0 ;i<=jary.length();i++)
{
JSONObject jread = jary.getJSONObject(i);
String id = jread.getString("question");
Log.d("value of id", ""+id);
id1.add(id);
String name = jread.getString("answer");
Log.d("value of id", ""+id);
question1.add(name);
Log.e("id","question is"+id);
Log.e("id","question is"+name);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
web.setText(""+id1+""+question1);
web.setMovementMethod(new ScrollingMovementMethod());
}
private String readTxt(){
InputStream inputStream = getResources().openRawResource(R.raw.details);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i;
try {
i = inputStream.read();
System.out.println("what"+i);
while (i != -1)
{
byteArrayOutputStream.write(i);
i = inputStream.read();
System.out.println("what_next"+i);
}
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return byteArrayOutputStream.toString();
}
}
但是,在那不通过uri字符串 – 2013-02-11 08:54:39
想想budy .....它真的帮我..... – 2013-02-12 11:29:05
至少有一个竖起大拇指 – Bora 2013-02-12 11:54:58
你能告诉我们你有什么尝试到现在?您是否能够通过网络拨打以获取上述数据?或者你解析JSON数据时遇到问题? – Romin 2013-02-11 07:36:29
我想获取这些数据并显示在我的应用程序屏幕上,但是可以请直到我怎么办..使用json – 2013-02-11 07:47:31
什么是从网站使用json解析获取这种数据的java代码.....你能帮我吗... plz – 2013-02-11 08:39:58