我已经为ViewPager创建了一个适配器。当我创建它时,我还必须在布局上动态创建单选按钮。但是,通过单击其中一个单选按钮,我需要对它所在的适配器执行notifyDataSetChanged操作。如何访问该适配器?例如,如果我想这样做:
radioButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
viewPagerLength++;
// need to call notifyDataSetChanged();
}
}});发布于 2013-03-25 07:49:12
这可以通过如下方式设置radioButton来完成:
final RadioButton radioButton = (RadioButton) findViewById(R.id.rb);
然后,您可以从内部访问radioButton。
https://stackoverflow.com/questions/10168271
复制相似问题