0

こんにちは私は1つのリストビューアプリの開発に成功しました。今、そのリストから任意のアイテムをクリックする必要があります。これは、詳細な説明が次のアクティビティで表示されることを意味します...これも正常に終了します。出力は以下の形式になります。

1   F   Krishna
2   Q   Danesh
3   P   Mercy

ここで、 2 Q Daneshアイテムをクリックする必要があります。次のアクティビティに移動します。次のアクティビティは、表示する必要があります。

Q Danesh

それはうまく機能しています。

しかし今、私はこのフォーマットのようなリストビューが必要になりたいです:

1 Krishna
2 Danesh
3 Mercy

ここで、 2つのDaneshをクリックする必要があります。これは、次のアクティビティに移動し、次のアクティビティを表示する必要があることを意味します

Q

どうすればいいですか....助けてください...

以下のコードは私のWebサービスコードです。

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

//顧客IDが最大である顧客情報を検索しますPreparedStatementstatement= con.prepareStatement( "SELECT * FROM xcart_orders"); ResultSet result = statement.executeQuery();

 while(result.next()){
   customerInfo = customerInfo 
            + result.getString("orderid") 
            + " "   // this to separate order id from status
            + result.getString("status") 
            + " " 
    // this to separate order id from status
            + result.getString("login") 
            + "&" ;
 //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;
}

 }

これは私のAndroidコードです:

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";
private static final String KEY_LOGIN = "login";


/** 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 =  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);            



            }
        });     
    }


    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 StrStatus = in.getStringExtra(KEY_STATUS);


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

  }
  }

私を助けてください....

4

1 に答える 1

1

可能です。Qをリスト画面から他のアクティビティに移動できます。

最初のアクティビティ(Q値)を変更する必要があります

in.putExtra("StrStatus", StrStatus);

そして、あなたは他の活動でこれを得ることができます

Bundle extras=getIntent().getExtras();
if(extras!=null) {
    STRStatus=extras.getString("StrStatus");
}

これにはQ値があり、好きなことを行うことができます。

-----
ところで-どのエラーが発生しますか?これを使用して、リストアイテムをクリックできます

public void onListItemClick(ListView parent,View v,int position,long id){
try {
    TextView t4=(TextView)v.findViewById(R.id.No);

    if (t4!=null){
        BeanClass/*ClassName*/  mSelected;
        int idx=position;
        mSelected=m_adapter.getItem(idx);           
        String ActionID=mSelected.getID();

        Intent intent=new Intent(this,SoneActivity.class);
        intent.putExtra("StrStatus", StrStatus);
        startActivity(intent);
    }
}
于 2012-09-19T10:33:45.933 に答える