JSON Android ListView

后端 未结 1 1017
醉酒成梦
醉酒成梦 2020-12-10 22:09

I build this webservice on netbeans,

package in.figures.on.mobile;

import db.koneksi.dbKoneksi;
import java.sql.Statement;
import java.sql.ResultSet;
import         


        
1条回答
  •  误落风尘
    2020-12-10 22:57

    Ok. Try this bellow code. It is full functional to me. You should implement the HttpRequest in the commented line. Pay atention to that the JSON array is hard-coded.

    // the Adapter
    public class ListViewAdapter extends BaseAdapter {
    
        private Context context = null;
        private List fields = null;
    
        public ListViewAdapter(Context context, JSONArray arr) {
            this.context = context;
            this.fields = new ArrayList();
            for (int i=0; i

    And the xml files:

    
    
        
            
            
        
    
    

    
    
        
    
    

    As result, it generates the following view:

    enter image description here

    Of course, you can customize it to create lists that you want, just parsing the jsons! Hope that I've helped in some way...

    0 讨论(0)
提交回复
热议问题