请检查这个编辑过的代码..它的工作但不显示数据库的数据..检查框正在勾选,但其他2列r打印为id和date ..我的setviewvalue方法没有弄错..
Either a c
答案 0 :(得分:0)
看起来不错,只需添加复选框点击,看一下。
public class MyCustomView : Java.Lang.Object, SimpleCursorAdapter.IViewBinder
{
public bool SetViewValue(View view, Android.Database.ICursor cursor, int i)
{
if (view.Id == Resource.Id.action_bar)
{
// If the column is IS_STAR then we use custom view.
int is_val = cursor.GetInt(i);
CheckBox cb = (CheckBox)view;
cb.Click += cb_Click;
if (is_val != 0)
{
// set the visibility of the view to GONE
cb.Checked = true;
return true;
}
else
{
// cb.Checked = false; //in case you want to make it (uncheck)
return true;
}
// For others, we simply return false so that the default binding
// happens.
}
return true;
}
void cb_Click(object sender, EventArgs e)
{
//Handle checkbox click because value will be cahnge while clicking on checkbox
}
}
答案 1 :(得分:0)
这段代码让我感谢你... :)
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
var cell : CollectionViewCell = collectionView.cellForItemAtIndexPath(indexPath) as! CollectionViewCell
cell.backgroundColor = UIColor.magentaColor()
self.mediaModels[indexPath.row].isSelected = true
cell.selected = true
cell.imageTicked.hidden = false
}
func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath){
var cell : CollectionViewCell = collectionView.cellForItemAtIndexPath(indexPath) as! CollectionViewCell
cell.backgroundColor = UIColor.whiteColor()
self.mediaModels[indexPath.row].isSelected = false
cell.selected = false
cell.imageTicked.hidden = true
}