How to display multiple strings into one Toast?












0















I made some strings that I could display using a Toast but I'm having trouble figuring out how to make them appear at the same time as a single Toast. So far I have this:



String text = input.getText().toString();
String text2= input2.getText().toString();
String text3 = input3.getText().toString();
Toast.makeText(getApplicationContext(),"Name: " + text,Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),"Age: " + text2,Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),"Occupation: " + text3,Toast.LENGTH_SHORT).show();


When I run the emulator, it shows the Toasts one at a time. Is there a way to display the name, age, and occupation at the same time?










share|improve this question





























    0















    I made some strings that I could display using a Toast but I'm having trouble figuring out how to make them appear at the same time as a single Toast. So far I have this:



    String text = input.getText().toString();
    String text2= input2.getText().toString();
    String text3 = input3.getText().toString();
    Toast.makeText(getApplicationContext(),"Name: " + text,Toast.LENGTH_SHORT).show();
    Toast.makeText(getApplicationContext(),"Age: " + text2,Toast.LENGTH_SHORT).show();
    Toast.makeText(getApplicationContext(),"Occupation: " + text3,Toast.LENGTH_SHORT).show();


    When I run the emulator, it shows the Toasts one at a time. Is there a way to display the name, age, and occupation at the same time?










    share|improve this question



























      0












      0








      0


      1






      I made some strings that I could display using a Toast but I'm having trouble figuring out how to make them appear at the same time as a single Toast. So far I have this:



      String text = input.getText().toString();
      String text2= input2.getText().toString();
      String text3 = input3.getText().toString();
      Toast.makeText(getApplicationContext(),"Name: " + text,Toast.LENGTH_SHORT).show();
      Toast.makeText(getApplicationContext(),"Age: " + text2,Toast.LENGTH_SHORT).show();
      Toast.makeText(getApplicationContext(),"Occupation: " + text3,Toast.LENGTH_SHORT).show();


      When I run the emulator, it shows the Toasts one at a time. Is there a way to display the name, age, and occupation at the same time?










      share|improve this question
















      I made some strings that I could display using a Toast but I'm having trouble figuring out how to make them appear at the same time as a single Toast. So far I have this:



      String text = input.getText().toString();
      String text2= input2.getText().toString();
      String text3 = input3.getText().toString();
      Toast.makeText(getApplicationContext(),"Name: " + text,Toast.LENGTH_SHORT).show();
      Toast.makeText(getApplicationContext(),"Age: " + text2,Toast.LENGTH_SHORT).show();
      Toast.makeText(getApplicationContext(),"Occupation: " + text3,Toast.LENGTH_SHORT).show();


      When I run the emulator, it shows the Toasts one at a time. Is there a way to display the name, age, and occupation at the same time?







      android






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 29 '16 at 20:49









      George Mulligan

      10.5k62845




      10.5k62845










      asked Jan 29 '16 at 20:48









      sam1319sam1319

      9112




      9112
























          3 Answers
          3






          active

          oldest

          votes


















          3














          Concatenate all of them together.



          Toast.makeText(getApplicationContext(),
          "Name: " + text
          + " Age: " + text2
          + " Occupation: " + text3,
          Toast.LENGTH_SHORT).show();





          share|improve this answer































            1














            Try this:



            Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();





            share|improve this answer































              0














              Try



              String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
              Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();





              share|improve this answer
























              • Or String data = String.Format("Name: {0}nAge: {1}nOccupation: {2}", text, text2, text3); or using interpolated strings in C#6 String data = $"Name: {text}nAge: {text2}nOccupation: {text3}";

                – PaulF
                Oct 12 '17 at 13:02











              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35093777%2fhow-to-display-multiple-strings-into-one-toast%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              Concatenate all of them together.



              Toast.makeText(getApplicationContext(),
              "Name: " + text
              + " Age: " + text2
              + " Occupation: " + text3,
              Toast.LENGTH_SHORT).show();





              share|improve this answer




























                3














                Concatenate all of them together.



                Toast.makeText(getApplicationContext(),
                "Name: " + text
                + " Age: " + text2
                + " Occupation: " + text3,
                Toast.LENGTH_SHORT).show();





                share|improve this answer


























                  3












                  3








                  3







                  Concatenate all of them together.



                  Toast.makeText(getApplicationContext(),
                  "Name: " + text
                  + " Age: " + text2
                  + " Occupation: " + text3,
                  Toast.LENGTH_SHORT).show();





                  share|improve this answer













                  Concatenate all of them together.



                  Toast.makeText(getApplicationContext(),
                  "Name: " + text
                  + " Age: " + text2
                  + " Occupation: " + text3,
                  Toast.LENGTH_SHORT).show();






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 29 '16 at 20:50









                  Rohit5k2Rohit5k2

                  14.3k42551




                  14.3k42551

























                      1














                      Try this:



                      Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();





                      share|improve this answer




























                        1














                        Try this:



                        Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();





                        share|improve this answer


























                          1












                          1








                          1







                          Try this:



                          Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();





                          share|improve this answer













                          Try this:



                          Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Oct 12 '17 at 11:55









                          Crime_Master_GoGoCrime_Master_GoGo

                          1,0861019




                          1,0861019























                              0














                              Try



                              String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
                              Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();





                              share|improve this answer
























                              • Or String data = String.Format("Name: {0}nAge: {1}nOccupation: {2}", text, text2, text3); or using interpolated strings in C#6 String data = $"Name: {text}nAge: {text2}nOccupation: {text3}";

                                – PaulF
                                Oct 12 '17 at 13:02
















                              0














                              Try



                              String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
                              Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();





                              share|improve this answer
























                              • Or String data = String.Format("Name: {0}nAge: {1}nOccupation: {2}", text, text2, text3); or using interpolated strings in C#6 String data = $"Name: {text}nAge: {text2}nOccupation: {text3}";

                                – PaulF
                                Oct 12 '17 at 13:02














                              0












                              0








                              0







                              Try



                              String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
                              Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();





                              share|improve this answer













                              Try



                              String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
                              Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Oct 12 '17 at 11:59









                              PehlajPehlaj

                              6,41472744




                              6,41472744













                              • Or String data = String.Format("Name: {0}nAge: {1}nOccupation: {2}", text, text2, text3); or using interpolated strings in C#6 String data = $"Name: {text}nAge: {text2}nOccupation: {text3}";

                                – PaulF
                                Oct 12 '17 at 13:02



















                              • Or String data = String.Format("Name: {0}nAge: {1}nOccupation: {2}", text, text2, text3); or using interpolated strings in C#6 String data = $"Name: {text}nAge: {text2}nOccupation: {text3}";

                                – PaulF
                                Oct 12 '17 at 13:02

















                              Or String data = String.Format("Name: {0}nAge: {1}nOccupation: {2}", text, text2, text3); or using interpolated strings in C#6 String data = $"Name: {text}nAge: {text2}nOccupation: {text3}";

                              – PaulF
                              Oct 12 '17 at 13:02





                              Or String data = String.Format("Name: {0}nAge: {1}nOccupation: {2}", text, text2, text3); or using interpolated strings in C#6 String data = $"Name: {text}nAge: {text2}nOccupation: {text3}";

                              – PaulF
                              Oct 12 '17 at 13:02


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35093777%2fhow-to-display-multiple-strings-into-one-toast%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Monofisismo

                              Angular Downloading a file using contenturl with Basic Authentication

                              Olmecas