我有DialogFragment contians listview有复选框和文本视图我希望保存状态的checkBox后检查我这样做保存了ISharedPreferences
中的状态但它没有工作
什么问题??
这是我的listViewNames适配器
`
public class ViewHoldername : Java.Lang.Object
{
public EditText etdName { get; set; }
public EditText etdTitle { get; set; }
}
class listViewNames : BaseAdapter<logINsnc.Customers_transfer>
{
private ISharedPreferences savePreferences;
static private ISharedPreferencesEditor savePrefsEditor;
private Boolean saveLogin;
public static CheckBox namechecbox ;
public static List<string> listNameChecked = new List<string>();
Activity activity;
List<logINsnc.Customers_transfer> ArriveList = new List<logINsnc.Customers_transfer>();
// SQliteDB bb = new SQliteDB();
logINsnc bb = new logINsnc();
async public Task<List<logINsnc.Customers_transfer>> Add_DataList(string s)
{
// string Get = ExpandableListAdapter.Globals.voucher;
ArriveList = await bb.DetailsNamelistForPOpUp(s);
return ArriveList;
}
public string GetVoucher()
{
string voucher = "";
return voucher;
}
public listViewNames()
{
}
public listViewNames(Activity activity, List<logINsnc.Customers_transfer> Arrive)
: base()
{
this.activity = activity;
this.ArriveList = Arrive;
}
public override int Count
{
get
{
return ArriveList.Count();
}
}
public override Java.Lang.Object GetItem(int position)
{
return position;
}
public override long GetItemId(int position)
{
return ArriveList[position].SrvOrd_Sub_Id;
}
public override logINsnc.Customers_transfer this[int position]
{
get { return ArriveList[position]; }
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
savePreferences = Application.Context.GetSharedPreferences("savePrefs", FileCreationMode.Private);
Globals.custimersCount = Count;
activity.LayoutInflater.Inflate(Resource.Layout.Details_Template, null);
var item = ArriveList[position];
View view = convertView;
if (view == null) // no view to re-use, create new
view = activity.LayoutInflater.Inflate(Resource.Layout.Custmize_Name_layout, null);
Globals.Ser_Sub = item.SrvOrd_Sub_Id;
view.FindViewById<TextView>(Resource.Id.etdNamelis).Text = item.Name.ToString();
view.FindViewById<TextView>(Resource.Id.etdTitle).Text = item.Title;
namechecbox = view.FindViewById<CheckBox>(Resource.Id.checkBoxnam);
// checkBoxButton = (CheckBox)convertView.FindViewById(Resource.Id.checkBoxButton);
namechecbox.Tag = item.Title + ";"+ position+";"+item.Name;
savePrefsEditor = savePreferences.Edit();
saveLogin = savePreferences.GetBoolean("saveLogind" + position + item.Name, false);
if (saveLogin == true)
{
namechecbox.Checked = true;
}
namechecbox.SetOnCheckedChangeListener(null);
namechecbox.SetOnCheckedChangeListener(new CheckedChangeListener(this.activity));
return view;
}
private class CheckedChangeListener : Java.Lang.Object, CompoundButton.IOnCheckedChangeListener
{
private Activity activity;
public CheckedChangeListener(Activity activity)
{
this.activity = activity;
}
public void OnCheckedChanged(CompoundButton buttonView, bool isChecked)
{
String[] tag = buttonView.Tag.ToString().Split(';');
string name = tag[0];
if (isChecked && !savePreferences.Contains("saveLogind" + tag[1] + tag[2] ))
{
savePrefsEditor.PutBoolean("saveLogind" + tag[1]+tag[2], true);
savePrefsEditor.Commit();
listNameChecked.Add(name);
Globals.listName = listNameChecked;
}
else
{
listNameChecked.Remove(name);
editor.Remove("saveLogind" + tag[1] + tag[2] );
savePrefsEditor.Commit();
Globals.listName = listNameChecked;
}
}
}
public static class Globals
{
public static int Ser_Sub { get; set; }
public static List<string> listName;
public static int custimersCount { get; set; }
// public static int TransName { get; set; }
public static string nameChecked { get; set; }
}
}
`