0

hi i have to developed one listview using soap calling.here i wish to implement one step..here i have to click any list means the detail description is display to next activity.how can i develop this.please help me..

this is my code:

public class RetailerActivity extends Activity {
ListView list;
private static final String SOAP_ACTION = "http://xcart.com/customerData1";
private static final String METHOD_NAME = "customerData1";
private static final String NAMESPACE = "http://xcart.com";
private static final String URL = "http://192.168.1.168:8089/XcartLogin/services/RetailerWs?wsdl";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    envelope.setOutputSoapObject(request);

    HttpTransportSE ht = new HttpTransportSE(URL);
    try {
        ht.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        SoapPrimitive s = response;
        String str = s.toString();
        String resultArr[] = str.split("&");//Result string will split & store in an array
        list=(ListView)findViewById(R.id.list);

        TextView tv = new TextView(this);

        for(int i = 0; i<resultArr.length;i++){
        tv.append(resultArr[i]+"\n\n");
       }
        setContentView(tv);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 }

this is my webservice code:

public class RetailerWs {
public String customerData1(){
String customerInfo = "";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/xcart-432pro","root","");
 //Find customer information where the customer ID is maximum
 PreparedStatement statement =  con.prepareStatement("SELECT * FROM xcart_orders");
 ResultSet result = statement.executeQuery();

 while(result.next()){
customerInfo = customerInfo + result.getString("orderid") + "&" + result.getString("status");
    //Here "&"s are added to the return string. This is help to split the string in Android application
   }
   }

 catch(Exception exc){
   System.out.println(exc.getMessage());
 }

return customerInfo;
}

  }

now i have to run the app means the orderid and status is fetched from database and displayed on my android app.here i wish to implement i have to click whichever order means that order status is displayed next activity.how can i develop this.please help me.

Kickaha
  • 3,680
  • 6
  • 38
  • 57
user1575906
  • 65
  • 1
  • 11
  • is it really necessary for your app to use SOAP based webservice call for implementing this functionality?? – Gautam Mandsorwale Sep 12 '12 at 10:16
  • yes....must use webservice call here – user1575906 Sep 12 '12 at 11:50
  • This is not a web services or ksoap2 question, you are asking how to assign the result from your web-service call to a list view and how to assign a listener to each list item to open a details activity. – Kickaha Sep 12 '12 at 12:01
  • [This](http://www.androidhive.info/2012/01/android-json-parsing-tutorial/) is an example that will help you with the generating listview and handling its item click. The Web service API used here is JSON, but you can take a look at how the service response is handled to create a listview and managing its onclick. Let me know if the problem still persists. – Gautam Mandsorwale Sep 12 '12 at 12:14

2 Answers2

0

you have lots of things to deal with here.

Don't reassign the content view.. that's bad thinking.

First you need to create an adapter follow the advice and links here

You then need to add a on click listener to open a new intent as is done here.

but your code is not ready for this step yet, you first need to create the adapter as above.

Go away and work on this, come back and ask a more specific question when you are ready.

Here is a more specific answer to the question you will have on how to open an intent within the on click listener in your adapter

Community
  • 1
  • 1
Kickaha
  • 3,680
  • 6
  • 38
  • 57
0

This is an example that will help you with the generating listview and handling its item click. The Web service API used here is JSON, but you can take a look at how the service response is handled to create a listview and managing its onclick. Let me know if the problem still persists.

Gautam Mandsorwale
  • 1,580
  • 1
  • 18
  • 27
  • hi i know android listview using json and xml parsing.but i wish to know calling soap.thanks for your help. – user1575906 Sep 15 '12 at 03:55
  • I know what you want, but your question here is how to handle the onclick of your listview and show the corresponding data in the next activity. Doesnt matter what service api you use. The link i gave will help you as a reference. – Gautam Mandsorwale Sep 17 '12 at 06:17