[英]How to reload the recycler view
I am creating an android application to save the passwords.我正在创建一个 android 应用程序来保存密码。 On the main screen i am using recycler view to show all the passwords.
在主屏幕上,我使用回收器视图来显示所有密码。 I have 2 two buttons one to add new password and second to update the password, when the user clicks on add new password, new activity (add new password activity) will be open.
我有 2 个按钮,一个是添加新密码,第二个是更新密码,当用户点击添加新密码时,新活动(添加新密码活动)将被打开。 how should i reload the recycler view on the main screen after returning from the add new password activity?
从添加新密码活动返回后,我应该如何在主屏幕上重新加载回收站视图?
i tried to recall the initial recyclerview function but it didn't worked.我试图回忆起最初的 recyclerview function 但它没有用。
addData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// action to be performed after it was clicked;
Intent i = new Intent(MainScreen.this, AddNewPassword.class);
i.putExtra("id", (String) null);
i.putExtra("Platform", "");
i.putExtra("User", "");
i.putExtra("password", "");
i.putExtra("boolean", false);
startActivity(i);
}
});
how should i refresh the current screen after returning fromm the AddNewPassword activity?从 AddNewPassword 活动返回后,我应该如何刷新当前屏幕?
Call notifyDataSetChanged after making changes:更改后调用 notifyDataSetChanged:
adapter.notifyDataSetChanged()
While comming back to first you have to override onResume method and in that method you have to bind that recyclerAdapter and last call.回到第一点时,您必须覆盖 onResume 方法,并且在该方法中,您必须绑定该 recyclerAdapter 和最后一次调用。
adapter.notifyDataSetChanged()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.