Hi
I have a question about passing data from Actvity to Fragment
This is my logic I have a Activity call ProductActivity this send Data to a MainActivity and this have a Default Fragment to show the detail of this product
I use EventBus to manage fragment
My first Activity Product have an Adapter to show many product and this have a button to send to the next activity
convertView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if( pro.getSync() == 1) {
Intent intent = new Intent(v.getContext(), com.example.activities.MainActivity.class);
intent.putExtra("product_id",pro.getProduct_id());
v.getContext().startActivity(intent);
}
}
});
In my Mainactivity have the displayInitialFragment and take the data from Intent
private void displayInitialFragment() {
Bundle extras = getIntent().getExtras();
String value = extras.getString("product_id");
getSupportFragmentManager().beginTransaction().replace( R.id.container, ProductDetailFragment.getInstance() ).commit();
mCurrentFragmentTitle = "Informes";
}
And now How i can take the data from the activity to my fragment??
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
?? Here i cant to undertand how take the data
textProyecto = (TextView)getView().findViewById(R.id.textView1);
textProyecto.setText(mBundle.getString("proyecto_id"));
}
Sorry for my english