私はこのjavascriptとアンドロイドのもので初心者です。他のアクティビティに追加結果を表示しようとしましたが、表示されませんでした
"EditView"から2つの数字を追加して他のアクティビティに表示しようとしています。 しかし、それは何も表示されませんでした。
ここにコードがあります。ここ
ます。public void lihathasil(ビューV){
thn1 = (EditText) findViewById(R.id.datat1);
thn2 = (EditText) findViewById(R.id.datat2);
thn3 = (EditText) findViewById(R.id.datat3);
thn4 = (EditText) findViewById(R.id.datat4);
thn1cus = Integer.parseInt(thn1.getText().toString());
thn2cus = Integer.parseInt(thn2.getText().toString());
thn3cus = Integer.parseInt(thn3.getText().toString());
thn4cus = Integer.parseInt(thn4.getText().toString());
ab = thn1cus + thn2cus + thn3cus + thn4cus;
Intent i = new Intent(getApplicationContext(), GeneralReport.class);
i.putExtra("pertama",ab);
startActivity(i);
}
そして、私はそれが表示何も実行したときに、他の活動のコードは、結果
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_general_report);
tam1=(TextView) findViewById(R.id.tampilsatu);
val1=getIntent().getExtras().getString("pertama");
tam1.setText(val1);
}
を表示しています。
誰でもそれを解決できます。 ありがとう
として定義されているのですか? 「getIntExtra」が赤色にマークされているためです。 –
次に、val1 = getIntent()。getExtras()。getIntExtra( "pertama"、0); –
はいgetExtras()を使用する場合はgetInt()です。 getIntent()でgetExtras()を呼び出すと、インテントに追加されたすべてのエクストラを含むBundleが返されるためです。しかし、単一の値が必要な場合は、getIntent()。getIntExtra( "key")を使用する方が優れています。 –