Bundle变为null并且没有使用bundle args

时间:2018-05-30 21:57:42

标签: android fragment bundle

我正在开发一个小型的Android应用程序,我正在使用共享首选项来在片段之间传输数据。现在我想使用bundle但问题是第二个片段中的bundle获取null值我该如何解决这个问题? 这是代码的一部分

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=25
MAIL_USERNAME=email@sub.domain.com
MAIL_PASSWORD=xxxxxxx
MAILGUN_SECRET=xxxxxxx
MAILGUN_DOMAIN=sub.domain.com
MAIL_ENCRYPTION=null

现在是第二个片段

... some usefull Code  in first fragment


args.putLong("favoriteCountry", countryListSpinnerData.get(favoriteCountrySpinner.getSelectedItemPosition()).getId());
                args.putInt("favoriteCurrency", currencySpinner.getSelectedItemPosition());
                args.putDouble("favoriteBudget", Double.parseDouble(budgetEditText.getText().toString()));
                args.putString("additionalInformation", additionalInformationEditText.getText().toString());
                MoneyPartnerShipStepTwo moneyPartnerShipStepTwo = new MoneyPartnerShipStepTwo();
                moneyPartnerShipStepTwo.setArguments(args);
                FragmentHelper.NAVIGATE_FRAGMENT(new MoneyPartnerShipStepTwo(), getActivity())

1 个答案:

答案 0 :(得分:0)

您创建新的MoneyPartnerShipStepTwo(),而不是您的参数的实例。 所以,请更改Private Sub TextBox1_Validating(sender As Object, e As CancelEventArgs) Handles TextBox1.Validating Try CurrencyManager.EndCurrentEdit() Catch ex As Exception MsgBox("The field C1 can not be empty") TextBox1.DataBindings(0).WriteValue() ' push the value to the datasource e.Cancel = True End Try End Sub