2012-01-09 1 views
0

내용 문자열과 이미지 URL이있는 JSON 데이터가 있는데 첫 번째 활동에서 이미 구문 분석합니다. 두 번째 작업의 맞춤 목록보기에서 주소록과 같이 표시 할 수있는 방법은 무엇입니까?JSON 파서의 데이터를로드하고 사용자 정의 된 목록보기에 표시하려면 어떻게해야합니까?

그게 해결책이라면 어떻게해야합니까?

어댑터에 익숙하지 않습니다.

다음은 첫 번째 활동에서 코드입니다 :

public class BBtest05Activity extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    try { 
     executeHttpGet(); 
    } catch (Exception e) { 
     Log.i("bird","parser failure"); 
     e.printStackTrace(); 
    } 
    } 

    String aStr = new String(); 
    String aStrArray[] = new String[2048]; 
    public void executeHttpGet() throws Exception { 
     try { 
     HttpClient client = new DefaultHttpClient(); 
     HttpGet request = new HttpGet("http://test.mobibon.com.tw/MovieGoTest/GetMovies.js"); 
     HttpResponse response = client.execute(request); 
     String retSrc = EntityUtils.toString(response.getEntity(),"utf-8"); 
     //there's a space in the head... 
     retSrc = retSrc.substring(1); 
      JSONObject obj = new JSONObject(retSrc); 
      JSONArray movieArray = obj.getJSONArray("movies"); 
      for(int i = 0;i < movieArray.length(); i++) 
      { 
      JSONObject movie_data = movieArray.getJSONObject(i); 
      aStr = aStr+","+movie_data.getString("cTitle"); 

      } 
      } finally { 
       aStrArray = aStr.split(","); 
       ListView list = (ListView) findViewById(R.id.linearLayout1); 
       list.setAdapter(new ArrayAdapter<String>(this, 
       android.R.layout.simple_list_item_1, aStrArray)); 
       list.setTextFilterEnabled(true); 
      } 
} 
public void aMethod(View theButton) { 
    Intent i = new Intent(this,nowamovie.class);  
    startActivity(i); 
} 

}

따른 방법으로는 변화 활동 방법 ...

다음 코드는 두 번째 활동에서 내 XML 파일입니다 ... .

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="match_parent" 
android:layout_width="fill_parent" 
android:orientation="vertical" android:background="@drawable/pic_background"> 
<LinearLayout android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:id="@+id/linearLayout1" > 
<ImageView android:layout_height="wrap_content" 
android:id="@+id/imageView1" 
android:layout_width="wrap_content" 
android:src="@drawable/ic_launcher"></ImageView> 
<TextView android:text="TextView" 
android:id="@+id/textView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_marginLeft="6dip" 
android:layout_marginTop="6dip" 
android:textAppearance="?android:attr/textAppearanceLarge"> 
</TextView> 
</LinearLayout> 
<LinearLayout android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:id="@+id/linearLayout1" 
android:orientation="horizontal"> 
<TextView android:id="@+id/textView2" 
android:text="TextView" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:textAppearance="?android:attr/textAppearanceSmall"> 
</TextView> 
<TextView android:text="TextView" android:id="@+id/textView3" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:textAppearance="?android:attr/textAppearanceSmall" 
android:layout_marginLeft="6dip"> 
</TextView> 
</LinearLayout> 

,

JSON 파서의 데이터를이 활동에 적용하려면 어떻게해야합니까?

답변

0

예. 어댑터를 사용자 정의하고 이미지 로딩이 게으르고 이미지가 게으른 구현을 위해 Google에서 검색해야하며 이에 대한 충분한 자료가 있어야합니다. 3.0에서는 새로운 기능인 Loader가 도입되었습니다.이 기능은이 지연로드 작업을 수행합니다.

+0

도움 주셔서 감사합니다. – bbbbbird1

관련 문제