0

我已经通过soap调用成功开发了android listview..现在我必须单击该列表中的任何项目意味着显示详细描述...

这是我的示例列表视图格式:

1 F
2 Q
3 P

在这里我需要单击 1 F 项目意味着 F 显示在下一个活动上。我必须单击 2 Q 表示 Q 显示在下一个活动上。

下一个活动必须像这样:(单击 1 F 表示它转到下一个活动并显示 F)

F

我该如何开发这个。请帮助我...

在这里,我必须单击 1 F 表示它进入下一个活动......下一个活动不会显示任何内容。

这是我的代码:

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();
    }
}

}

这是另一个活动:

 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);

}
}

这是 single_list_item.xml 文件是:

<?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>

请帮助我..我该如何开发这个。

4

1 回答 1

2

在这里我认为 onItemClick 你没有得到价值所以得到像

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);                  

        }
    });  

有关将 ActivityA 传递给 B 并获得价值的更多价值,请参见此处,这可能会对您有所帮助

于 2012-09-18T12:52:36.023 回答