1

Send request format is

{"method":"item_list","parameter":{"category_id":"1"}}

I want to pass json on btn_choose_menu click

package com.example.pattipizza;

import android.os.Bundle;
import android.view.View;`enter code here`
import android.view.View.OnClickListener;
import android.widget.Button;

public class OrderSelect extends MainActivity {

    Button btn_choose_menu, btn_send_order;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.varified_activity);
        btn_choose_menu = (Button) findViewById(R.id.button1);

        btn_choose_menu.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

            }
        });
        btn_send_order.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

            }
        });

    }
}
Hi-Angel
  • 4,933
  • 8
  • 63
  • 86

1 Answers1

0

For obtaining the data from the server you should use the doInBackground method of the AsyncTask. All code contained in this method is executed in another thread and doesn't block your UI, to avoid an ANR. In the onPostExecute method you should update your list view in the UI thread. Parsing xml or JSON is described in this and this article. In this article you can see how network operations can be performed using the AsyncTask class.

Performing JSON post requests is described in the accepted answer of this resource.

Community
  • 1
  • 1
Patrick Leitermann
  • 2,144
  • 2
  • 13
  • 13