2017-11-19 11 views
0

これは例です。バンドルを使用しているため、「donationType」というシンボルを解決できないことを示すエラーが表示されます。Bundle.getString()でキーを設定するときにエラーが発生する

Intent intent = new Intent(context, supporterLayoutTwo.class); 
       //Create the bundle 
       Bundle bundle = new Bundle(); 

       //Add your data to bundle 
       bundle.putString(“donationType”, donationtype); 
       intent.putExtras(bundle); 
       startActivity(intent); 

答えて

1

donationtypeを定義する必要があります。たとえば:

int donationtype = 15; 
String donationtype = "Donate"; 

Intent intent = new Intent(context, supporterLayoutTwo.class); 
       //Create the bundle 
       Bundle bundle = new Bundle(); 

       String donationtype = "donation"; 
       //Add your data to bundle 
       bundle.putString(“donationType”, donationtype); 
       intent.putExtras(bundle); 
       startActivity(intent); 
+0

問題ありません、以下試してください:それはあります。それがうまくいけば答えを受け入れることができますか? –

+0

ありがとう、今私は他の活動に設定されているhae プライベートストリングdonationtype; //バンドルを取得する バンドルバンドル= getIntent()。getExtras(); //データを抽出します。 donationtype = bundle.getString( "donationType");それはシンボルdonationTypeを解決できないと言っています。 –

+0

Declare String donationtype;最初に値を割り当てます。そうでなければdonationtypeは存在しません –

関連する問題