-2
我proplem是:我有功能LoadTaskList()
上MainActivity
,但在CustomAdapter我叫LoadTaskList()
但它並不活躍呼叫功能
CustomAdapter.cs
public override View GetView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = (LayoutInflater)mainActivity.GetSystemService(Context.LayoutInflaterService);
View view = inflater.Inflate(Resource.Layout.row, null);
TextView txtTask = view.FindViewById<TextView>(Resource.Id.task_title);
Button btnDelete = view.FindViewById<Button>(Resource.Id.btnDelete);
txtTask.Text = taskList[position];
btnDelete.Click += delegate {
string task = taskList[position];
dbHelper.deleteTask(task);
mainActivity.LoadTaskList(); // here
};
return view;
}
MainActivity.cs
public void LoadTaskList()
{
List<string> taskList = dbHelper.getTaskList();
if (mAdapter == null)
{
mAdapter = new CustomAdapter(this, taskList,dbHelper);
lstTask.Adapter = mAdapter;
}
}
你是什麼意思_「但它不活躍」?_你得到一個錯誤? –
這個函數重新加載ListView,但在我的情況下,它不會重新加載ListView,當你調用CustomAdapter時 – EddyLee
當你第二次調用它時是'mAdapter == null'? duh – mihail