我的列表视图项目不可见

时间:2014-07-31 21:22:53

标签: php android

我是印度的工程专业学生。 我正在我的大学里做一个提交项目 我在php中使用webservice。 Json解析.... 早些时候我得到了正确的输出,但突然间我不知道我犯了什么错误,我的意思是当我执行我的程序下一个tym时我得到了一个带有隐形视图的列表..在最后一行有一个详细视图,但早些时候它充满了所有的细节..我使用我的localhost作为服务器。

enter code here

代码: -

public class C_List extends ListActivity {
    private ProgressDialog pDialog;
    public static String selected_college;
    private static final String url = "my localhost ip and db addres.. ";


    public static String Tag_id;
    public static String Tag_college_name;
    public static String Tag_affiliation; 
    public static String Tag_address;
    public static String Tag_contact; 
    public static String Tag_email;
    public static String Tag_website;   
    public static String Tag_longitude; 
    public static String Tag_latitude;  

    public static String id;
    public static String college_name;
    public static String affiliation; 
    public static String address;
    public static String contact; 
    public static String email;
    public static String website;   
    public static String longitude; 
    public static String latitude;  


    JSONArray colleges =null;

    ArrayList<HashMap< String ,String>> collegelist;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);
        collegelist= new ArrayList<HashMap<String,String>>();

        new Getcollegelist().execute();

    }
    public  class Getcollegelist extends AsyncTask<Void, Void, Void>{



        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(C_List.this);
            pDialog.setMessage("Please Wait.....");
            pDialog.setCancelable(false);
            pDialog.show();
        }

        @Override
        protected Void doInBackground(Void... arg0) {
            ServiceHandler sh = new ServiceHandler();
            String jsonString=  sh.makeServiceCall(url, ServiceHandler.GET);

            if (jsonString != null) {
                try{                    
                    JSONObject jsonObject= new JSONObject(jsonString);
                    colleges = jsonObject.getJSONArray("colleges");

                    for (int i = 0; i < colleges.length() ; i++) {
                        JSONObject jsonObject2 = colleges.getJSONObject(i);
                        Bitmap bmp;
                        id= jsonObject2.getString("c_id");
                        college_name= jsonObject2.getString("college_name");
                        affiliation =jsonObject2.getString("Affiliation");
                        address=jsonObject2.getString("address");
                        contact=jsonObject2.getString("contact_no");
                        email=jsonObject2.getString("email");
                        website=jsonObject2.getString("website");
                        String qrimage=jsonObject2.getString("image");
                        byte[] image=Base64.decode(qrimage.getBytes(), i);
                        bmp = BitmapFactory.decodeByteArray(image,0,image.length);

                        contact = jsonObject2.getString("contact_no");

                        HashMap<String, String> collMap = new HashMap<String, String>();
                        collMap.put(id,id);
                        collMap.put(college_name, college_name);
                        collMap.put(address, address);

                        collegelist.add(collMap);
                    }   
                }
                catch (JSONException e) {
                    e.printStackTrace();
                }
            } else
            {
                Log.e("ServiceHandler", "Couldn't get any data from the url");
            }

            return null;
        }




        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);

            pDialog.dismiss();
            ListAdapter adapter= new SimpleAdapter(C_List.this, collegelist , R.layout.text,new String[] {id,college_name, address},
                    new int[] {R.id.id, R.id.name, R.id.address} );
            setListAdapter(adapter);

        }}
}

List.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView 
        android:id="@+id/listbanner"
        android:layout_width="fill_parent"
        android:layout_height="80dp"/>

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:dividerHeight="2dp"

        android:divider="#000"
        android:padding="3dp"
        android:textFilterEnabled="true" />


</LinearLayout>

0 个答案:

没有答案
相关问题