Search code examples
androidparsingandroid-listviewlistadapterandroid-ksoap2

android listview via soap calling


i have developed android listview via soap calling is successfully..now i have to click any item from that list means the detail description is displayed...

this is my sample listview format:

1 F
2 Q
3 P

here i need to click the 1 F item means the F is display on next activity.samething i have to click 2 Q means the Q is display on next activity.

Next activity have to Like this :(click 1 F means it is go to next activity and display F)

F

how can i develop this.please help me...

Here i have to click the 1 F means it is go to next activity...nothing is displayed on next activity.

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";
private static final String KEY_STATUS = "status";



/** 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("&");
        list=(ListView)findViewById(R.id.list);


        list.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1,resultArr));
        list.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {


                String status = ((TextView) view.findViewById(R.id.status)).getText().toString();

                Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
                in.putExtra(KEY_STATUS, status);
                startActivity(in);                  

            }
        });     
    }


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

}

This is another activity:

 public class SingleMenuItemActivity  extends Activity {

// XML node keys
static final String KEY_STATUS = "status";

@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.single_list_item);

    Intent in = getIntent();
    String status = in.getStringExtra(KEY_STATUS);


    // Displaying all values on the screen
    TextView lblName = (TextView) findViewById(R.id.status_label);
    lblName.setText(status);

}
}

This is single_list_item.xml file is:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Name Label -->
 <TextView android:id="@+id/status_label"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="25dip"
        android:textStyle="bold"
        android:paddingTop="10dip"
        android:paddingBottom="10dip"
        android:textColor="#dc6800"
       />

 </LinearLayout>

please help me..how can i develop this.


Solution

  • here i think onItemClick you not getting value so get values like

    list.setOnItemClickListener(new OnItemClickListener() {    
            @Override
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    
             String status =  parent.getItemAtPosition(position).toString();
             String[] status1  = status.split(" ");
             String StrStatus = status1[1].toString();
    
                Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
                in.putExtra(KEY_STATUS, StrStatus );
                startActivity(in);                  
    
            }
        });  
    

    for more value passing ActivityA to B and get value see here this may helps you