2012-03-11 37 views
0

嗨,我有一個名單上有它的標題填充從JSON供稿,現在我想將圖像添加到其繼承人我single_list佈局Android的餵食圖像送入列表

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="?android:attr/listPreferredItemHeight" 

    android:padding="6dip"> 

    <ImageView 
     android:id="@+id/icon" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentTop="true" /> 

<TextView 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
    android:background="@drawable/ic_gr_arrow" 
    android:id="@+id/textView1" 
    android:textColor="@color/blue" 
    android:padding="20dp" 
    android:textSize="10dp" 

    /> 


</RelativeLayout> 

繼承人從JSON提要一個新聞故事的一個例子,我認爲這image_small我需要

{"code":200,"error":null,"data":{"news":[{"news_id":"8086","title":"Tickets for Player of the Year award on general sale","tagline":"Event to be held Sunday 25th March at Holiday Inn, Barnsley","content":"Tickets for the inaugural Evo-Stik NPL Player of the Year event are now on sale to the general public.\r\n\r\nPriced at \u00a335, tickets include a three course meal, plus entertainment from renowned tenor Martin Toal and guest speaker Fred Eyre.\r\n\r\nAwards at the event include the Player and Young Player of the Year for each division, as well as divisional teams of the year, the Fans\u2019 Player of the Year and a League Merit award.\r\n\r\nTo purchase your ticket, send a cheque for \u00a335 payable to \u201cNorthern Premier League\u201d to Alan Ogley, 21 Ibberson Avenue, Mapplewell, Barnsley, S75 6BJ. Please include a return address for the tickets to be sent to, and the names of those attending. \r\n\r\nFor more information, e-mail Tom Snee or contact Event organiser Alan Ogley on 07747 576 415\r\n\r\nNote: Clubs can still order tickets by e-mailing Angie Firth - simply state how many tickets you require and you will be invoiced accordingly.\r\n\r\nAddress of venue: Barnsley Road, Dodworth, Barnsley S75 3JT (just off Junction 37 of M1)","created":"2012-02-29 12:00:00","category_id":"1","img":"4539337","category":"General","fullname":"Tom Snee","user_id":"170458","image_user_id":"170458","image_file":"1330519210_0.jpg","image_width":"600","image_height":"848","sticky":"1","tagged_division_id":null,"tagged_team_id":null,"tagged_division":null,"tagged_team":null,"full_image":"http:\/\/images.pitchero.com\/up\/league-news-default-full.png","image_primary":"http:\/\/images.pitchero.com\/ui\/170458\/lnl_1330519210_0.jpg","image_secondary":"http:\/\/images.pitchero.com\/ui\/170458\/lns_1330519210_0.jpg","image_original":"http:\/\/images.pitchero.com\/ui\/170458\/1330519210_0.jpg","image_small":"http:\/\/images.pitchero.com\/ui\/170458\/sm_1330519210_0.jpg"} 

和繼承人到目前爲止我的代碼

String json = reader.readLine(); 





      // Instantiate a JSON object from the request response 
      JSONObject obj = new JSONObject(json); 
      List<String> items = new ArrayList<String>(); 


      JSONObject objData = obj.getJSONObject("data"); 

      JSONArray jArray = objData.getJSONArray("news"); 


      for (int i=0; i < jArray.length(); i++) 
      { JSONObject oneObject = jArray.getJSONObject(i); 
       items.add(oneObject.getString("title")); 
       Log.i("items", "items"); 
      } 

      setListAdapter (new ArrayAdapter<String>(this, R.layout.single_item, items)); 
      ListView list = getListView(); 
      list.setTextFilterEnabled(true); 


      list.setOnItemClickListener(new OnItemClickListener(){ 

       public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, 
         long arg3) { 
        // TODO Auto-generated method stub 
        Toast.makeText(getApplicationContext(), ((TextView) arg1).getText(),1000).show(); 
       } 



      }); 


     } catch(Exception e){ 
      // In your production code handle any errors and catch the individual exceptions 
      e.printStackTrace(); 
     } 

回答