Reputation: 563
I Am new to the Android,I need to send an sms which will Contain the following content e.g: "1"+"\n"+"f_name"+"l_name"+"roll";i am storing these information in arraylist.can anyone suggest me how to perform the operation.i have done some operations.
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
System.out.println("RN-->>created parser");
SAXXMLHandlerChalanForm ch = new SAXXMLHandlerChalanForm();
xr.setContentHandler(ch);
xr.parse(new InputSource(getAssets().open("Chalan.xml")));
ArrayList<ChalanFormDTO> chalanList = ch.getChalanData();
System.out.println("size of ChalanList" + chalanList.size());
for (int i = 0; i < chalanList.size(); i++) {
if (chalanNum.equalsIgnoreCase(chalanList.get(i).getChalanNo()))
{ text_chalanNo.setText(chalanList.get(i).getChalanNo());
text_buyName.setText(chalanList.get(i).getBuyerName());
text_date.setText(chalanList.get(i).getDates());
text_sales.setText(chalanList.get(i).getSales());
System.out.println("Size of LISTOFITEMS:\n"
+ chalanList.get(i).getListOfStock().size());
for (int j = 0; j < chalanList.get(i).getListOfStock()
.size(); j++) {
TableRow tr1 = new TableRow(this);
tr1.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
TextView tv9 = new TextView(this);
tv9.setText(String.valueOf(j+1));
tv9.setBackgroundResource(R.drawable.border_top);
tv9.setTextColor(getResources().getColor(R.color.Black));
tv9.setLayoutParams(new TableRow.LayoutParams(dpwidth/2,
LayoutParams.WRAP_CONTENT));
tv9.setGravity(Gravity.CENTER_HORIZONTAL);
tv9.setMinimumWidth(dpwidth);
tr1.addView(tv9);
TextView tv4 = new TextView(this);
tv4.setText(chalanList.get(i).getListOfStock().get(j)
.getName());
tv4.setBackgroundResource(R.drawable.border_top);
tv4.setTextColor(getResources().getColor(R.color.Black));
tv4.setLayoutParams(new TableRow.LayoutParams(dpwidth,
LayoutParams.WRAP_CONTENT));
tv4.setGravity(Gravity.CENTER_HORIZONTAL);
tv4.setMinimumWidth(dpwidth);
tr1.addView(tv4);
TextView tv6 = new TextView(this);
tv6.setText(chalanList.get(i).getListOfStock().get(j)
.getQuantity());
tv6.setBackgroundResource(R.drawable.border_top);
tv6.setTextColor(getResources().getColor(R.color.Black));
tv6.setLayoutParams(new TableRow.LayoutParams(dpwidth,
LayoutParams.WRAP_CONTENT));
tv6.setGravity(Gravity.CENTER_HORIZONTAL);
tv6.setMinimumWidth(dpwidth);
tr1.addView(tv6);
table.addView(tr1, 3);
}
}
}
} catch (Exception e) {
// TODO: handle exception
}
Upvotes: 2
Views: 149
Reputation: 1316
You can append the arraylist data inside a stringbuffer using a for loop.
create a stringbuffer like
StringBuffer strbuf = new StringBuffer();
for(int i = 0; i<chalanList.size; i++)
{
strbuf.append("1\n");
strbuf.append("f_name: "+chalanList.get(i).f_name);
strbuf.append(chalanList.get(i).getChalanNo());
strbuf.append(chalanList.get(i).getBuyerName());
. . .
}
after your insertion is complete send it to sms.
Upvotes: 1