2013-02-11 3 views
-2

이것은 내 웹 서비스 데이터입니다.이 종류의 웹 서비스에서 데이터를 가져 오는 방법

[ 
    { 
     "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" 
    } 
] 

JSON 구문 분석을 사용하여 Android에서이 데이터를 앱으로 가져올 수 있습니까? 유 나를 도울 수이 데이터 .... PLZ에 대한 자바 코드 무엇 ....

+0

당신은 당신이 무엇을 말해 수 지금까지 해봤습니까? 위의 데이터를 얻기 위해 네트워크 호출을 할 수 있었습니까? 아니면 JSON 데이터를 파싱하는 데 문제가 있습니까? – Romin

+0

이 데이터를 가져와 내 응용 프로그램 화면에 표시하려고 시도하고 있지만 할 수있는 방법까지 나에게 줄 수 있습니다. json 사용 –

+0

json 파싱을 사용하여 웹 사이트에서 이러한 종류의 데이터를 가져 오는 Java 코드는 무엇입니까 ..... u는 나를 도울 수 ... plz –

답변

0

공용 클래스 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(); 
     } 

}

+0

하지만, 그 URI를 전달하지 않는 문자열 –

+0

..... budy ..... 정말 나를 도와 ..... ..... –

+0

적어도 하나의 엄지 손가락 친구 – Bora

관련 문제