【发布时间】:2013-12-24 22:27:04
【问题描述】:
我目前正在开发一个带有两个列表(在不同片段中)和复选框的应用程序。
几张截图展示给你看:
现在我希望能够
1) 使用 «save» 按钮保存所有复选框状态(并使用 «load» 按钮加载它们)
2) “链接”复选框,这样如果我在会谈屏幕中点击一个复选框,它也会在论文屏幕中被点击。
我知道我可以通过使用 SharedPreferences 来保存这些,但它们是使用适配器构建的,所以我所拥有的只是
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
// We only create the view if its needed
if (view == null) {
view = inflater.inflate(R.layout.child_row, null);
// Set the click listener for the checkbox
view.findViewById(R.id.check1).setOnClickListener(this);
}
Paper p = (Paper) getItem(position);
// Set the example text and the state of the checkbox
CheckBox cb = (CheckBox) view.findViewById(R.id.check1);
//cb.setChecked(p.isSelected());
// We tag the data object to retrieve it on the click listener.
TextView paper = (TextView)view.findViewById(R.id.papername);
if (paper != null)
paper.setText(p.getTitle());
TextView author = (TextView)view.findViewById(R.id.authorname);
if( author!= null )
author.setText( p.getAuthor() );
return view;
}
所以每个复选框都没有标识符。这是我可以简单处理的问题吗?
非常感谢!
【问题讨论】:
标签: android checkbox android-fragments