我的片段会显示交易。这是一个recyclerView。当我从片段中单击一个事务时,它将以具有相应值的形式显示,我可以删除或更新它。
如何在开始另一项活动之前通过我的片段所连接的片段关闭活动?
答案 0 :(得分:0)
很抱歉没有更新我的问题也没有给出答案。经过试验,我只想在片段构造函数上传递活动,然后使用activity.Finish();当我点击回收站视图中的项目时
private Expense_Objects expenseObject;
private Denomination_Objects denominationObject;
private Activity activity;
/// <summary>
/// Fragment for Petty Cash
/// </summary>
/// <param name="expenseObject">Expense Object</param>
/// <param name="denominationObject">Denomination Object</param>
/// <param name="activity">Activity where fragment will reside</param>
public Fragment_PettyCash(Expense_Objects expenseObject,
Denomination_Objects denominationObject, Activity activity)
{
this.pcExpenseObject = pcExpenseObject;
this.denominationObject = denominationObject;
this.activity = activity;
}
/// <summary>
/// Setting up recyclerView
/// </summary>
/// <param name="recyclerView">recyclerView</param>
private void setUpRecyclerView(RecyclerView recyclerView)
{
recyclerView.SetLayoutManager(new LinearLayoutManager(recyclerView.Context));
recyclerView.SetAdapter(new SimpleStringRecyclerViewAdapter(recyclerView.Context,
expenseObject.payeeList, expenseObject.totalAmountList));
recyclerView.SetItemClickListener((rv, position, view) =>
{
//doing other stuffs
Context context = view.Context;
Intent intent = new Intent(context, typeof(UpdateDeleteExpense));
intent.PutExtra(IntentExtras.denominationSerialized,
JsonConvert.SerializeObject(denominationObject));
intent.PutExtra(IntentExtras.pettyCashExpenseSerialized,
JsonConvert.SerializeObject(expenseObject));
context.StartActivity(intent);
activity.Finish();
}
);
}