How to display multiple strings into one Toast?
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
add a comment |
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
add a comment |
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
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
android
edited Jan 29 '16 at 20:49
George Mulligan
10.5k62845
10.5k62845
asked Jan 29 '16 at 20:48
sam1319sam1319
9112
9112
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Concatenate all of them together.
Toast.makeText(getApplicationContext(),
"Name: " + text
+ " Age: " + text2
+ " Occupation: " + text3,
Toast.LENGTH_SHORT).show();
add a comment |
Try this:
Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();
add a comment |
Try
String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Concatenate all of them together.
Toast.makeText(getApplicationContext(),
"Name: " + text
+ " Age: " + text2
+ " Occupation: " + text3,
Toast.LENGTH_SHORT).show();
add a comment |
Concatenate all of them together.
Toast.makeText(getApplicationContext(),
"Name: " + text
+ " Age: " + text2
+ " Occupation: " + text3,
Toast.LENGTH_SHORT).show();
add a comment |
Concatenate all of them together.
Toast.makeText(getApplicationContext(),
"Name: " + text
+ " Age: " + text2
+ " Occupation: " + text3,
Toast.LENGTH_SHORT).show();
Concatenate all of them together.
Toast.makeText(getApplicationContext(),
"Name: " + text
+ " Age: " + text2
+ " Occupation: " + text3,
Toast.LENGTH_SHORT).show();
answered Jan 29 '16 at 20:50
Rohit5k2Rohit5k2
14.3k42551
14.3k42551
add a comment |
add a comment |
Try this:
Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();
add a comment |
Try this:
Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();
add a comment |
Try this:
Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();
Try this:
Toast.makeText(this, "data = " +t_amount+ "" +order_no+ "" +ph_no, Toast.LENGTH_SHORT).show();
answered Oct 12 '17 at 11:55
Crime_Master_GoGoCrime_Master_GoGo
1,0861019
1,0861019
add a comment |
add a comment |
Try
String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();
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
add a comment |
Try
String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();
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
add a comment |
Try
String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();
Try
String data = "Name: " + text + "n" + " Age: " + text2 + "n" + " Occupation: " + text3;
Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG).show();
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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