1

嗨,这是我的 xml 提要。

<feed>
  <Order>
   <orderid>1</orderid>
   <login>krishna</login>
   <total>399.99</total>
   <payment_method>Check (manual processing)</payment_method>                                  
   <firstname>krishnaveni</firstname>
   <lastname>v</lastname>
  </Order>
  <Order>
   <orderid>65</orderid>
   <login>krishna</login>
   <total>399.99</total>
   <payment_method>Phone Ordering</payment_method>
   <firstname>krishnaveni</firstname>
   <lastname>v</lastname>
 </Order>
</feed>

下面的 CustomizedListview.java 从上面的 xml 提要执行 listview...它工作...在这里我必须单击列表中的任何顺序意味着它是转到下一个活动..下一个活动一个状态(微调器)字段。 .状态值的更新取决于上面的orderid ...我如何开发dis ...在插入示例中必须显示从customisedlistview解析的orderid值...现在我希望状态更新取决于这个orderid ..如何我可以管理我的代码吗……请帮帮我……

这是我的 android 代码: CustomizedListview:

    public class CustomizedListView extends Activity {
// All static variables
static final String URL = "http://192.168.1.168/xcart432pro/orderdetails.xml";
static final String KEY_SONG = "Order"; // parent node
static final String KEY_ID = "orderid";
static final String KEY_TITLE = "orderid";
static final String KEY_DATE = "date";
static final String KEY_ARTIST = "payment_method";
static final String KEY_STATUS = "status";
static final String KEY_DURATION = "total";
static final String KEY_FNAME = "firstname";
static final String KEY_LNAME = "lastname";
static final String KEY_NAME = "login";

ListView list;
LazyAdapter adapter;

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


    ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();

    XMLParser parser = new XMLParser();
    String xml = parser.getXmlFromUrl(URL); // getting XML from URL
    Document doc = parser.getDomElement(xml); // getting DOM element

    NodeList nl = doc.getElementsByTagName(KEY_SONG);
    // looping through all song nodes <song>
    for (int i = 0; i < nl.getLength(); i++) {
        // creating new HashMap
        HashMap<String, String> map = new HashMap<String, String>();
        Element e = (Element) nl.item(i);
        // adding each child node to HashMap key => value
        map.put(KEY_ID, parser.getValue(e, KEY_ID));
        map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
        map.put(KEY_ARTIST, parser.getValue(e, KEY_ARTIST));
        map.put(KEY_STATUS, parser.getValue(e, KEY_STATUS));
        map.put(KEY_FNAME, parser.getValue(e, KEY_FNAME));
        map.put(KEY_LNAME, parser.getValue(e, KEY_LNAME));
        songsList.add(map);
    }


    list=(ListView)findViewById(R.id.list);

    // Getting adapter by passing xml data ArrayList
    adapter=new LazyAdapter(this, songsList);        
    list.setAdapter(adapter);


    // Click event for single list row
    list.setOnItemClickListener(new OnItemClickListener() {

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


            // Starting new intent
            Intent in = new Intent(getApplicationContext(), InsertionExample.class);

             startActivity(in);                 

        }
    });     
}   

}

这是我的 InsertionExample.java:

public class UpdationExample extends Activity{
EditText userName, userPassword ;
private final String NAMESPACE = "http://xcart.com";
private final String URL = "http://192.168.1.168:8089/XcartLogin/services/Updation?wsdl";
private final String SOAP_ACTION = "http://xcart.com/insertData";
private final String METHOD_NAME = "insertData";
static final String KEY_NAME = "orderid";
Button btninsert;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
      Intent in = getIntent();

    // Get XML values from previous intent
    String orderid = in.getStringExtra(KEY_NAME);

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


    lblName.setText(orderid);
    btninsert = (Button)findViewById(R.id.btn_insert);
    btninsert.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
         insertValues();
        }
    });
}

public void insertValues(){
 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
 EditText userName = (EditText) findViewById(R.id.editText1);
 String user_Name = userName.getText().toString();
 EditText userPassword = (EditText) findViewById(R.id.editText2);
 String user_Password = userPassword.getText().toString();

 //Pass value for userName variable of the web service
    PropertyInfo unameProp =new PropertyInfo();
    unameProp.setName("userName");//Define the variable name in the web service method
    unameProp.setValue(user_Name);//Define value for fname variable
    unameProp.setType(String.class);//Define the type of the variable
    request.addProperty(unameProp);//Pass properties to the variable

  //Pass value for userPassword variable of the web service
    PropertyInfo passwordProp =new PropertyInfo();
    passwordProp.setName("userPassword");
    passwordProp.setValue(user_Password);
    passwordProp.setType(String.class);
    request.addProperty(passwordProp);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try{
     androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();

        TextView result = (TextView) findViewById(R.id.textView2);
        result.setText(response.toString());

 }
 catch(Exception e){

 }
}

}

这里用户名和密码的更新取决于上面 xml 提要中的 orderid

4

0 回答 0