Android stringbuilder元素 [英] Android stringbuilder elements
本文介绍了Android stringbuilder元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
你会好像看看我的代码下面的代码并帮助
从stringbuilder中检索字符串。我想要做的是拆分stringbuilder,将其转换为字符串并获取第一个和第二个
元素,并将它们用作数据库的包输入。
提前感谢< br $>
Hello all,
would you be kind to have a look a look at the piece of my code bellow and help
with string retrieve from stringbuilder. What I want to do is split the stringbuilder, convert it to string and get the 1st and 2nd
element and use them as bundle input for database.
Thanks in advance
@Override
public void onClick(View v) {
StringBuilder checkedcontacts= new StringBuilder();
System.out.println(".............."+ma.mCheckStates.size());
for(int i = 0; i < name1.size(); i++)
{
if(ma.mCheckStates.get(i)==true)
{
checkedcontacts.append(name1.get(i).toString());
checkedcontacts.append(" ");
checkedcontacts.append(phno1.get(i).toString());
}
else
{
System.out.println("Not Checked......"+name1.get(i).toString());
}
}
Toast.makeText(Display.this, checkedcontacts,
Toast.LENGTH_SHORT).show();
推荐答案
可能它应该像这样改变:
Probably it should change like this:
for(int i = 0; i < name1.size(); i++)
{
if(ma.mCheckStates.get(i)==true)
{
checkedcontacts.append(name1.get(i).toString());
checkedcontacts.append(" ");
checkedcontacts.append(phno1.get(i).toString());
break; // break your loop
}
else
{
System.out.println("Not Checked......"+name1.get(i).toString());
}
}
Toast.makeText(Display.this, checkedcontacts.toString(),
Toast.LENGTH_SHORT).show(); // you didn't use toString()
这篇关于Android stringbuilder元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文