【发布时间】:2014-07-07 20:01:46
【问题描述】:
我想知道我做错了什么,因为我的应用程序无法编译。 setonCheckedChangeListener(this);要求演员。 我正在尝试从由“,”分隔的内容中添加复选框(内容是通过 JSON 下载的)
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class SingleContactActivity extends Activity {
int array_Count=0;
// The next part is in the onCreate method, after the data has been pulled out of my intent.
String[] seperatedString = list.split(", ");
Array_Count=seperatedString.length;
LinearLayout my_layout = (LinearLayout)findViewById(R.id.list_label);
for (int i = 0; i < Array_Count; i++)
{
TableRow row =new TableRow(this);
row.setId(i);
row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
CheckBox checkBox = new CheckBox(this);
checkBox.setOnCheckedChangeListener(this);
checkBox.setId(i);
checkBox.setText(seperatedString[i]);
row.addView(checkBox);
my_layout.addView(row);
}
非常感谢任何帮助。
【问题讨论】: