Android 在TextView中添加和显示意图
我有一个Android 在TextView中添加和显示意图,android,string,android-intent,textview,Android,String,Android Intent,Textview,我有一个EditText,用户写了一个金额。然后当他们进入下一个活动时与其他文本视图一起显示的金额 这是按钮: /** Called when the user clicks the Deposit button */ public void bnkDepBtn(View view) { Intent intent = new Intent(BankDeposit.this, BankDepositConfirm.class); EditText editText = (Edit
EditText
,用户写了一个金额。然后当他们进入下一个活动时
与其他文本视图
一起显示的金额
这是按钮
:
/** Called when the user clicks the Deposit button */
public void bnkDepBtn(View view) {
Intent intent = new Intent(BankDeposit.this, BankDepositConfirm.class);
EditText editText = (EditText) findViewById(R.id.bnk_dep_amount);
String DepAmount = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, DepAmount);
startActivity(intent);
finish();
}
然后这是下一个活动
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
public class BankDepositConfirm extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bank_deposit_confirm);
// Get the message from the intent
Intent intent = getIntent();
String DepAmount = intent.getStringExtra(BankDeposit.EXTRA_MESSAGE);
}
这就是我要添加到的xml
问题是
我无法在应用程序中显示文本。如何在新的
活动中使用额外消息
数据
就像调用字符串一样
您只需得到如下值
String DepAmount = getIntent().getStringExtra(EXTRA_MESSAGE//Content);
TextView textview = (TextView) findviewByid(value);
textview.setText(DepAmount );
在名为类的意图中使用此选项:
String a=getIntent().getExtras().getString(EXTRA_MESSAGE);
TextView tName = (TextView) findViewById(R.id.prev_pad_textView1);
tName.setText(a);
到底是什么问题?我无法让文本显示在应用程序中。如何在新活动中使用额外的消息数据,如调用字符串。
String a=getIntent().getExtras().getString(EXTRA_MESSAGE);
TextView tName = (TextView) findViewById(R.id.prev_pad_textView1);
tName.setText(a);