我有像三個複選框下面三個複選框值爲
的Facebook CheckBox1 GOOGLEPLUS CheckBox2 Twitter的CheckBox3
我曾嘗試下面的代碼:
if (facebookChackbox.isChecked())
{
facebook_checkbox = true;
AppUtil.facebookNetworkList_EditPost ="Facebook";
list.add("facebook");
Intent i = new Intent();
i.putExtra("facebook_boolean", true);
Log.e("facebook checkbox", "facebook checkbox" + facebook_checkbox);
}
else
{
AppUtil.facebookNetworkList_EditPost ="";
}
if (twitterChackbox.isChecked())
{
twitter_checkbox = true;
AppUtil.twitterNetworkList_EditPost ="Twitter";
list.add("twitter");
Intent i = new Intent();
i.putExtra("twitter_boolean", true);
Log.e("twitter checkbox", "twitter checkbox" + twitter_checkbox);
}
else
{
AppUtil.twitterNetworkList_EditPost ="";
}
if (googleChackbox.isChecked())
{
AppUtil.gpNetworkList_EditPost ="Google Plus";
googleplus_checkbox = true;
list.add("gplus");
Intent i = new Intent();
i.putExtra("google_plus_boolean", true);
Log.e("google plus checkbox", "google plus checkbox" + googleplus_checkbox);
}
else
{
AppUtil.gpNetworkList_EditPost ="";
}
AppUtil.SocialNetworkingList_EditPost = AppUtil.facebookNetworkList_EditPost+""+AppUtil.twitterNetworkList_EditPost+""+AppUtil.gpNetworkList_EditPost;
我宣佈APPUTIL類中的所有這些Static字符串。
當我檢查所有的複選框,或一個或兩個,它給我null,null,null取決於檢查chechk框。
我想複選框的值與選中的複選框。
private void processCheckboxes() {
// TODO Auto-generated method stub
list = new ArrayList<String>();
sb = new StringBuilder();
if (facebookChackbox.isChecked())
{
facebook_checkbox = true;
AppUtil.facebookNetworkList_EditPost ="Facebook";
list.add("facebook");
Intent i = new Intent();
i.putExtra("facebook_boolean", true);
Log.e("facebook checkbox", "facebook checkbox" + facebook_checkbox);
}
else
{
AppUtil.facebookNetworkList_EditPost ="";
}
if (twitterChackbox.isChecked())
{
twitter_checkbox = true;
AppUtil.twitterNetworkList_EditPost ="Twitter";
list.add("twitter");
Intent i = new Intent();
i.putExtra("twitter_boolean", true);
Log.e("twitter checkbox", "twitter checkbox" + twitter_checkbox);
}
else
{
AppUtil.twitterNetworkList_EditPost ="";
}
if (googleChackbox.isChecked())
{
AppUtil.gpNetworkList_EditPost ="Google Plus";
googleplus_checkbox = true;
list.add("gplus");
Intent i = new Intent();
i.putExtra("google_plus_boolean", true);
Log.e("google plus checkbox", "google plus checkbox" + googleplus_checkbox);
}
else
{
AppUtil.gpNetworkList_EditPost ="";
}
AppUtil.SocialNetworkingList_EditPost = AppUtil.facebookNetworkList_EditPost+""+AppUtil.twitterNetworkList_EditPost+""+AppUtil.gpNetworkList_EditPost;
for (int zz = 0; zz < list.size(); zz++) {
network = list.get(zz);
if (zz < list.size() - 1)
{
Log.i("list.size()",""+list.size());
Log.i("list.size() - 1",""+list.size());
Log.i("network",""+network);
sb.append(network + "," + network + "," + network);
Log.i("sb",""+sb);
}
else
{
Log.e("log", "List----" + zz + network);
network_list = network;
network_list = network + "," + network + "," + network;
// network_list=network+""+network+"&gplus="+network+"&twitter"+
// "" +network;
sb.append(network + "," + network + "," + network);
}
}
}
以上是我現在正在調用該方法,我想選中的值存儲在字符串中,並希望利用它來進行設置text.But我收到facebookfacebookfacebook,意味着重複字符串的是發生。
您確定要創建改變監聽器每次都有一個新的Intent對象? –
,我只是想獲得檢查複選框存儲在字符串中的值在一些文本視圖中使用 – Amrinder
把你的錯誤日誌在這裏 –