在Bundle.getString()中设置密钥时出错

时间:2017-11-19 01:01:37

标签: android

这是例子,我使用的是Bundle,它向我显示一个错误,表明无法解析符号' donationType'。

 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 个答案:

答案 0 :(得分:1)

你必须定义什么是捐赠类型。例如:是a:

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);