嗨,我想在 Android 应用程序中创建动态数量的复选框(这取决于数组“流派”的长度),然后我做了:
CheckBox [] checkbox;
String [] genre={"party","sport","music","café","education"};
@Override
protected void onCreate(Bundle savedInstanceState) {
checkbox=new CheckBox[genre.length];
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_checkbox);
for(int i=0;i<genre.length;i++){
CheckBox c=new CheckBox(this);
c.setText(genre[i]);
checkbox[i]=c;
}
ArrayAdapter<CheckBox>adapter= new ArrayAdapter<CheckBox>(this, android.R.layout.simple_list_item_1,checkbox);
ListView lv= (ListView)findViewById(R.id.genre_list);
lv.setAdapter(adapter);
}
但是在列表视图中它显示了内存中复选框的数量(我猜),为什么?
like : Android.wiget.CheckBox@44f03160
Android.wiget.CheckBox@44f03d60
...