I am here with a fresh question. I have a card layout in a fragment. One of the card has a button upon click which I open a new activity.
if("activity1".equals(button.getTag())){
Intent intent1 = new Intent(itemView.getContext(), MainActivity2.class);
itemView.getContext().startActivity(intent1);
}
My MainActivity2.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
pDialog = new ProgressDialog(this);
images = new ArrayList<>();
mAdapter = new GalleryAdapter(getApplicationContext(), images);
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
MainActivity2 loads images from a server. When I click the button and open open, MainActivity2.java, I want to toast a message "Please wait while we load things for you". I tried the below:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Toast.makeText(this, this.getIntent().getExtras().getString("value"),Toast.LENGTH_LONG).show();
But its not working. How can I solve this problem?
What is the "value" extra? where it comes from?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Toast.makeText(this, "Please wait while we load things for you", Toast.LENGTH_LONG).show();
}