0

If you allow, my friends. I am still new in the world of the Android. I am looking for the code of the basket button in the picture.

I have 4 activities. I want to collect the data entered in each activity through button send to the basket and store this data temporarily in the basket button until the completion of the collection of data from all activities. Then when pressing the basket button, I want to send this data to a new activity showing all the data Which was stored in the basket button.

I read a lot about this topic, and all the answers were about getTag and setTag. But I really did not know how to handle this code. Can anyone help me explain more about this instruction and how can I deal with it? Thank you very much.

This code that I try, does it send text and price to button??

 Button fab;

 Intent intent = new Intent( this, FloatingActionButton.class );
 String keyIdentifer  = null;
 intent.putExtra( "String", text );
 intent.putExtra( "Int", price );
 fab.setTag( "input" );

And in the button code I used this code to send the received data to the last activity when you press the button. Is this correct???

    final FloatingActionButton fab = (FloatingActionButton) findViewById( R.id.fab );
    fab.setOnClickListener( new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent( MainActivity.this, Main3Activity.class );
            fab.getTag( Integer.parseInt( "input" ) );
            startActivity( intent );
        }
    } );
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • 2
    Welcome to StackOverflow! Please read the info about [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and [how to give a reproducible example](https://stackoverflow.com/help/mcve). This will make it much easier for others to help you. – avariant Apr 10 '18 at 20:05
  • Well I've tweaked it – Nouran Katana Apr 11 '18 at 01:09

1 Answers1

2

You can pass data between activities using Intents and Parcelables

If I got your question right, my idea is to create a MainActivity that will start new activities for result, waiting for the response(if a product was added to the basket), and when the user clicks on the basket, you pass all collected data to the checkout activity using the Intents.

ps: Use the intents to get the response from the products activities.

Massita
  • 309
  • 2
  • 10