خرید بک لینک
iv class="vote">

Vote count: 0

i write a program for retrieve a entire list from mysql database but while i executing the program it gets all value in list view but i want the whole coloumn in one item in list view, pls help me

this is my parser class,,

Parser.java

public class Parser extends AsyncTask<Void, String, Integer> {

    Context context;
    String data;
    ListView listView;

    ArrayList<String> allData=new ArrayList<String>();
    ProgressDialog pd;



    public Parser(Context context, String data, ListView listView) {
        this.context = context;
        this.data = data;
        this.listView = listView;
    }

    @Override
    protected Integer doInBackground(Void... params) {
        return this.parse();
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();

        pd=new ProgressDialog(context);
        pd.setTitle("Parser");
        pd.setMessage("Parsing data...pls wait!!!");
        pd.show();
    }

    @Override
    protected void onPostExecute(Integer integer) {
        super.onPostExecute(integer);
        if (integer == 1)
        {
            ArrayAdapter<String> adapter=new ArrayAdapter<String>(context,android.R.layout.simple_list_item_1,allData);
            listView.setAdapter(adapter);


            listView.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, allData) {
//
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {


                View view = super.getView(position, convertView, parent);
                view.setMinimumHeight(300);

                TextView textView = ((TextView) view.findViewById(android.R.id.text1));
                TextView textView1 = ((TextView) view.findViewById(android.R.id.text2));
//                textView.setMinHeight(0); // Min Height
//                textView.setMinimumHeight(0); // Min Height
//                textView.setHeight(44); // Height
                textView.setTextSize(18);

                return view;

            }
        });


            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Snackbar.make(view,allData.get(position), Snackbar.LENGTH_SHORT).show();
                }
            });
        }
        else
        {
            Toast.makeText(context,"Unable to parse",Toast.LENGTH_SHORT).show();
        }
        pd.dismiss();
    }
    private int parse()
    {
        try {
            //add data to the json array first
            JSONArray ja=new JSONArray(data);
            //create jo object to hold  A SIngle item
            JSONObject jo=null;

            allData.clear();
            //loop through array
            for (int i=0;i<ja.length();i++)
            {
                jo=ja.getJSONObject(i);
                //retrive name
                String address=jo.getString("Address");
                String con1=jo.getString("Contact_no");
                String con2=jo.getString("contact_2");
                String con3=jo.getString("contact3");
                String con4=jo.getString("contact4");
                String email=jo.getString("Email");


                //add it to our arrayList
                allData.add(address);
                allData.add(con1);
                allData.add(con2);
                allData.add(con3);
                allData.add(con4);
                allData.add(email);

            }
            return 1;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return 0;

    }
}

asked 27 secs ago

برچسب: i want to be your lady baby,i want to,i want to be your lady baby dance,i want to see,i want to believe,i want to know,i want to go home,i want to know what love is,i want to hold your hand,i want to be ninja, نویسنده: استخدام کار تاريخ: سه شنبه 19 مرداد 1395 ساعت: 12:26

صفحه بندی

خبرنامه