0

文字列をアクティビティに送信したい:

public class MyHttpClientUsage {

  public MyHttpClientUsage(){}

  public void getInfoAbout() throws HttpException{

    RequestParams params = new RequestParams();
    params.put("a", "Static");
    params.put("content", "47");

    MyHttpClient.get("", params, new AsyncHttpResponseHandler(){
      @Override
      public void onSuccess(String response) {
        System.out.println(response);
        //How can I send this response
      }

    });
  }
}

メソッドが静的であるため、インテントを使用できget()ません。そのため、コンテキストなどをインスタンス化できませんMyHttpClient

4

3 に答える 3

1

文字列を処理するためにリスナーを作成できます。このようなSmth:http: //docs.oracle.com/javase/tutorial/uiswing/events/index.html

于 2013-02-04T14:05:55.910 に答える
1
Bundle basket2 = new Bundle();
    basket2.putInt("ID", 3);
            Intent yourIntent = new Intent("YourActivity");
            yourIntent.putExtras(basket2);
            startActivity(YourIntent);
于 2013-02-04T14:06:12.710 に答える
0

これを試して...

最初のアクティビティで

inputName = (EditText) findViewById(R.id.name);
        Button btnNextScreen = (Button) findViewById(R.id.btnNextScreen);

        //Listening to button event
        btnNextScreen.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                //Starting a new Intent
                Intent nextScreen = new Intent(getApplicationContext(), SecondScreenActivity.class);

                //Sending data to another Activity
                nextScreen.putExtra("name", inputName.getText().toString());

                Log.e("n", inputName.getText());

                startActivity(nextScreen);

            }
        });

次のアクティビティで

 Intent i = getIntent();
        // Receiving the Data
        String name = i.getStringExtra("name");
        Log.e("Second Screen", name);

        // Displaying Received data
        txtName.setText(name);
于 2013-02-04T14:12:35.000 に答える