-1

私はカリ コロンビア出身です。英語は話せません。

私は activityA と activityB を持っています ボタン activityA
クリック ボタン セット テキスト activityB = setText ("100");

 public void onClick(View arg0) {


    Intent manu = new Intent (MainActivity.this,Sonido.class);

    setContentView(R.layout.activity_main2);                
    ((TextView) findViewById(R.id.textView21)).setText("100");

startActivity(manu);

/*
1.getText()
2.putString()
3.getString()

.take data from a string and show activity B
.The button is only in the activity
*/


}

私のような質問: 別のアクティビティからボタンを呼び出す

4

2 に答える 2

2

-アクティビティ A とアクティビティ B

-アクティビティ B にはボタン mbutt があります。

アクティビティ A からアクティビティ B への移動

A ----> B (B has button mbutt)

アクティビティ A :

Intent i = new Intent(A.this, B.class);
i.putExtra("key","100");
startActivity(i);

アクティビティ B:

Button mbutt = (Button)findViewById(R.id.myButt);
Intent intent = getIntent();
String value = intent.getStringExtra("key");
mbutt.setText(value);
于 2012-09-17T05:54:52.417 に答える
0

そのための明示的な意図を作ることができます。文字列をインスタンス化した後、intent.putextra()メソッドを使用して文字列を配置します。settext.getextras()を使用して、他のアクティビティで文字列を取得します。次に、異なるが対応する文字列を次のアクティビティに書き込む場合は、switchステートメントを使用できます。

于 2012-09-17T05:35:44.273 に答える