Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TicketFragment extends Fragment {
- ListView tv;
- public TicketFragment(){}
- private String TAG ="Vik";
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_ticket, container, false);
- tv =(ListView)rootView.findViewById(R.id.listView1);
- AsyncCallWS task = new AsyncCallWS();
- task.execute();
- return rootView;
- }
- private class AsyncCallWS extends AsyncTask<Void, Void, Void> {
- @Override
- protected Void doInBackground(Void... params) {
- location();
- return null;
- }
- @Override
- protected void onPostExecute(Void result) {
- // Log.i(TAG, "onPostExecute");
- }
- @Override
- protected void onPreExecute() {
- // Log.i(TAG, "onPreExecute");
- }
- @Override
- protected void onProgressUpdate(Void... values) {
- //Log.i(TAG, "onProgressUpdate");
- }
- }
- public void location()
- {
- String SOAP_ACTION = "http://example.com/getlocations";
- String SOAP_ACTION2 = "http://example.com/getaddress";
- String METHOD_NAME = "getlocations";
- String METHOD_NAME2 = "getaddress";
- String NAMESPACE = "http://example.com/";
- String URL = "http://100.100.00.00/example/Service.asmx";
- try {
- SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
- SoapObject Request2 = new SoapObject(NAMESPACE, METHOD_NAME2);
- SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
- SoapEnvelope.VER11);
- SoapSerializationEnvelope soapEnvelope2 = new SoapSerializationEnvelope(
- SoapEnvelope.VER11);
- soapEnvelope.dotNet = true;
- soapEnvelope.setOutputSoapObject(Request);
- soapEnvelope.setOutputSoapObject(Request2);
- HttpTransportSE transport= new HttpTransportSE(URL);
- transport.call(SOAP_ACTION, soapEnvelope);
- transport.call(SOAP_ACTION2, soapEnvelope2);
- SoapObject response = (SoapObject)soapEnvelope.getResponse();
- SoapObject response2 = (SoapObject)soapEnvelope2.getResponse();
- System.out.println(response);
- int intPropertyCount = response.getPropertyCount();
- String[] locations= new String[intPropertyCount];
- for (int i = 0; i < intPropertyCount; i++)
- {
- locations[i] = response.getPropertyAsString(i).toString();
- }
- System.out.println(response2);
- int intPropertyCount2 = response2.getPropertyCount();
- String[] address= new String[intPropertyCount2];
- for (int i = 0; i < intPropertyCount; i++)
- {
- address[i] = response2.getPropertyAsString(i).toString();
- }
- final ArrayAdapter<String> adapter =
- new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, locations);
- final ArrayAdapter<String> adapter2 =
- new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_2, address);
- getActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- // This code will always run on the UI thread, therefore is safe to modify UI elements.
- tv.setAdapter(adapter);
- tv.setAdapter(adapter2);
- tv.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
- Intent intent = new Intent(getActivity(), CreateTicket.class);
- // add data to the intent...
- startActivity(intent);
- }
- });
- }
- });
- }
- catch(Exception ex) {
- Log.e(TAG, "Error: " + ex.getMessage());
- }
- }
- }
- SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
- SoapObject Request2 = new SoapObject(NAMESPACE, METHOD_NAME2);
- SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
- SoapSerializationEnvelope soapEnvelope2 = new SoapSerializationEnvelope(
- SoapEnvelope.VER11);
- soapEnvelope.dotNet = true;
- soapEnvelope.setOutputSoapObject(Request);
- soapEnvelope.setOutputSoapObject(Request2); // should be soapEnvelope2.setOutputSoapObject(Request2);
- <?xml version="1.0" encoding="utf-8"?>
- <TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/text1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:minHeight="?android:attr/listPreferredItemHeight"
- />
- lv.setAdapter(new ArrayAdapter<String>(this,R.layout.custom_layout,R.id.text1,location));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement