在Bundle中获取值但是当将该bundle值放在string中时,它显示为null值。这是我的代码:
活性:1
public void btnDeposite(View v)
{
s1 = e1.getText().toString();
amt1 = Integer.parseInt(s1);
Intent i =new Intent(this,Transfer.class);
i.putExtra("depositeAmount", amt1);
startActivity(i);
}
活性:2
//在onCreate()
中 b = getIntent().getExtras();
s1 = b.getString("depositeAmount");
答案 0 :(得分:2)
int s1 = b.getInt("depositeAmount");
答案 1 :(得分:1)
这是因为您要将amt1
更改为int
s1 = e1.getText().toString();
amt1 = Integer.parseInt(s1);
并将值作为String
获取s1 = b.getString("depositeAmount");
将其更改为
s1 = b.getInt("depositeAmount");
希望这有助于!! !!
由于
答案 2 :(得分:0)
将getString
替换为getInt
int s1 = b.getInt("depositeAmount");