Convert Arraylist to a list of items to share through Whatsapp
i'm developing an App which has an Arraylist with the name of the product and its quantity. Now i want to make an Intent to share this information like a list through the WhatsApp and e-mail, example:
Product: product1 Quantity: 2
Product: product2 Quantity: 5
Product: product3 Quantity: 1
Product: product4 Quantity: 7
or
Product: product1
Quantity: 2
Product: product2
Quantity: 5
Product: product3
Quantity: 1
Product: product4
Quantity: 7
It must send all the information at once like a list.
java android arraylist
add a comment |
i'm developing an App which has an Arraylist with the name of the product and its quantity. Now i want to make an Intent to share this information like a list through the WhatsApp and e-mail, example:
Product: product1 Quantity: 2
Product: product2 Quantity: 5
Product: product3 Quantity: 1
Product: product4 Quantity: 7
or
Product: product1
Quantity: 2
Product: product2
Quantity: 5
Product: product3
Quantity: 1
Product: product4
Quantity: 7
It must send all the information at once like a list.
java android arraylist
1
meta.stackoverflow.com/questions/284236/…
– Iłya Bursov
Nov 15 '18 at 17:07
add a comment |
i'm developing an App which has an Arraylist with the name of the product and its quantity. Now i want to make an Intent to share this information like a list through the WhatsApp and e-mail, example:
Product: product1 Quantity: 2
Product: product2 Quantity: 5
Product: product3 Quantity: 1
Product: product4 Quantity: 7
or
Product: product1
Quantity: 2
Product: product2
Quantity: 5
Product: product3
Quantity: 1
Product: product4
Quantity: 7
It must send all the information at once like a list.
java android arraylist
i'm developing an App which has an Arraylist with the name of the product and its quantity. Now i want to make an Intent to share this information like a list through the WhatsApp and e-mail, example:
Product: product1 Quantity: 2
Product: product2 Quantity: 5
Product: product3 Quantity: 1
Product: product4 Quantity: 7
or
Product: product1
Quantity: 2
Product: product2
Quantity: 5
Product: product3
Quantity: 1
Product: product4
Quantity: 7
It must send all the information at once like a list.
java android arraylist
java android arraylist
edited Nov 15 '18 at 23:47
Allan Jaqueira
asked Nov 15 '18 at 17:06
Allan JaqueiraAllan Jaqueira
114
114
1
meta.stackoverflow.com/questions/284236/…
– Iłya Bursov
Nov 15 '18 at 17:07
add a comment |
1
meta.stackoverflow.com/questions/284236/…
– Iłya Bursov
Nov 15 '18 at 17:07
1
1
meta.stackoverflow.com/questions/284236/…
– Iłya Bursov
Nov 15 '18 at 17:07
meta.stackoverflow.com/questions/284236/…
– Iłya Bursov
Nov 15 '18 at 17:07
add a comment |
1 Answer
1
active
oldest
votes
So you want to convert the ArrayList which contains strings as
" product1 , 5 "
"Product2 , 3" ...
To one String to share? If so you can use this code.
{
ArrayList<String> dataList = new ArrayList<>();
// Your arraylist that contains all the data
dataList.add("product1 , 5");
dataList.add("Product2 , 3");
StringBuilder fullString = new StringBuilder();
for (int i=0 ; i < dataList.size(); i++)
{
String splitedData = dataList.get(i).split(",");
fullString.append("Product : " + splitedData[0] + "n" + "Quantity : "+ splitedData[1]+"n");
}
ShareToWhatsapp(fullString.toString());
}
Understood, but in my case i already have the Arraylist that's been feeded from the firestore. it's a shopping list with the list from the client.
– Allan Jaqueira
Nov 15 '18 at 19:13
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%2f53324594%2fconvert-arraylist-to-a-list-of-items-to-share-through-whatsapp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
So you want to convert the ArrayList which contains strings as
" product1 , 5 "
"Product2 , 3" ...
To one String to share? If so you can use this code.
{
ArrayList<String> dataList = new ArrayList<>();
// Your arraylist that contains all the data
dataList.add("product1 , 5");
dataList.add("Product2 , 3");
StringBuilder fullString = new StringBuilder();
for (int i=0 ; i < dataList.size(); i++)
{
String splitedData = dataList.get(i).split(",");
fullString.append("Product : " + splitedData[0] + "n" + "Quantity : "+ splitedData[1]+"n");
}
ShareToWhatsapp(fullString.toString());
}
Understood, but in my case i already have the Arraylist that's been feeded from the firestore. it's a shopping list with the list from the client.
– Allan Jaqueira
Nov 15 '18 at 19:13
add a comment |
So you want to convert the ArrayList which contains strings as
" product1 , 5 "
"Product2 , 3" ...
To one String to share? If so you can use this code.
{
ArrayList<String> dataList = new ArrayList<>();
// Your arraylist that contains all the data
dataList.add("product1 , 5");
dataList.add("Product2 , 3");
StringBuilder fullString = new StringBuilder();
for (int i=0 ; i < dataList.size(); i++)
{
String splitedData = dataList.get(i).split(",");
fullString.append("Product : " + splitedData[0] + "n" + "Quantity : "+ splitedData[1]+"n");
}
ShareToWhatsapp(fullString.toString());
}
Understood, but in my case i already have the Arraylist that's been feeded from the firestore. it's a shopping list with the list from the client.
– Allan Jaqueira
Nov 15 '18 at 19:13
add a comment |
So you want to convert the ArrayList which contains strings as
" product1 , 5 "
"Product2 , 3" ...
To one String to share? If so you can use this code.
{
ArrayList<String> dataList = new ArrayList<>();
// Your arraylist that contains all the data
dataList.add("product1 , 5");
dataList.add("Product2 , 3");
StringBuilder fullString = new StringBuilder();
for (int i=0 ; i < dataList.size(); i++)
{
String splitedData = dataList.get(i).split(",");
fullString.append("Product : " + splitedData[0] + "n" + "Quantity : "+ splitedData[1]+"n");
}
ShareToWhatsapp(fullString.toString());
}
So you want to convert the ArrayList which contains strings as
" product1 , 5 "
"Product2 , 3" ...
To one String to share? If so you can use this code.
{
ArrayList<String> dataList = new ArrayList<>();
// Your arraylist that contains all the data
dataList.add("product1 , 5");
dataList.add("Product2 , 3");
StringBuilder fullString = new StringBuilder();
for (int i=0 ; i < dataList.size(); i++)
{
String splitedData = dataList.get(i).split(",");
fullString.append("Product : " + splitedData[0] + "n" + "Quantity : "+ splitedData[1]+"n");
}
ShareToWhatsapp(fullString.toString());
}
edited Nov 15 '18 at 18:26
answered Nov 15 '18 at 18:16
raed ghazalraed ghazal
104
104
Understood, but in my case i already have the Arraylist that's been feeded from the firestore. it's a shopping list with the list from the client.
– Allan Jaqueira
Nov 15 '18 at 19:13
add a comment |
Understood, but in my case i already have the Arraylist that's been feeded from the firestore. it's a shopping list with the list from the client.
– Allan Jaqueira
Nov 15 '18 at 19:13
Understood, but in my case i already have the Arraylist that's been feeded from the firestore. it's a shopping list with the list from the client.
– Allan Jaqueira
Nov 15 '18 at 19:13
Understood, but in my case i already have the Arraylist that's been feeded from the firestore. it's a shopping list with the list from the client.
– Allan Jaqueira
Nov 15 '18 at 19:13
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%2f53324594%2fconvert-arraylist-to-a-list-of-items-to-share-through-whatsapp%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
1
meta.stackoverflow.com/questions/284236/…
– Iłya Bursov
Nov 15 '18 at 17:07