我有以下代码:
// If CheckBox is toggled, update the planet it is tagged with.
checkBox.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v ;
Planet planet = (Planet) cb.getTag();
planet.setChecked( cb.isChecked() );
**ArrayList<String> FavList = new ArrayList<String>();
FavList.add(planet.name);**
}
});
public void test (View view){
Intent myintent = new Intent (getApplicationContext(), MultipleItemsList.class);
myintent.putExtra("name", FavList);
startActivity(myintent);
}
}
我想要做的是将选中的行星添加到“FavList”,然后在单击按钮时填充列表。方法测试已加入按钮,但我收到错误 FavList 无法解析为变量