Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DonationsActivity extends FragmentActivity {
- private DonationsFragment donationsFragment = null;
- . . .
- // (INSTANTITATE THE DONATIONS FRAGMENT AS IN THE EXAMPLE)
- @Override
- public void onCreate(Bundle savedInstanceState) {
- . . .
- this.donationsFragment = DonationsFragment.newInstance(. . .);
- . . .
- }
- // How I solved it
- @Override
- protected void onPostCreate(@Nullable Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- try {
- Button googleDonationsButton = donationsFragment.getActivity()
- .findViewById(R.id.donations__google_android_market_donate_button);
- googleDonationsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- try {
- donationsFragment.donateGoogleOnClick(v);
- } catch (IllegalStateException e) {
- new MaterialDialog.Builder(DonationsActivity.this)
- .title(R.string.donations__google_android_market_not_supported_title)
- .content(R.string.donations__google_android_market_not_supported)
- .cancelable(true)
- .positiveText(R.string.accept)
- .build().show();
- }
- }
- });
- } catch (NullPointerException e) {
- Log.e("DonationsActivity", "Unable to get button-fragment. Full trace: "
- + e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement