Skip to content Skip to sidebar Skip to footer

Pass Mainactivity's Data To Tab Fragment

I'm new to android and java but in my very first app I'm kinda doing play store, the first thing you see on play store and then go to the second activity and see that whole list th

Solution 1:

you need use Intent in order to send data to another activity

@OverridepublicvoidonClick(View v) {

    Bookbook=newBook(mBkTitle.getText().toString(),
            mBkAuthor.getText().toString());

    Intentintent=newIntent(MainActivity.this, BookActivity.class);
    intent.putExtra("Book", book);
    startActivity(intent);
  }

data need to extends from Parcelable

publicclassBookimplementsParcelable{
  // book basicsprivateString title;
  privateString author;
}

use http://www.jsonschema2pojo.org/ to help you make class parcelable.

Check this tutorial

https://code.tutsplus.com/tutorials/how-to-pass-data-between-activities-with-android-parcelable--cms-29559

Post a Comment for "Pass Mainactivity's Data To Tab Fragment"