现在我正在尝试将关键数据从片段传递到包含 recyclerview 的适配器,但问题是在我的情况下无法使用 bundle 或使用意图发送数据我很困惑如何传递数据..
这是我的片段
package com.example.together.fragment;
public class PetchingLoungeFragment extends Fragment {
private static final String TAG = "PetFirendsFragment";
RecyclerView recyclerView;
PetchingLoungeAdapter petchingLoungeAdapter;
List<User> userList;
FirebaseUser firebaseUser;
List<String> idList = new ArrayList<>();
public String petKey;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_petching_lounge, container, false);
recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Lounge").child("PetchingBunyang").child(firebaseUser.getUid()).child("PetId");
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot ds : dataSnapshot.getChildren())
{
String id = ds.getKey();
PetchingLoungeFragment petchingLoungeFragment = new PetchingLoungeFragment(); // Fragment 생성
Bundle bundle = new Bundle(1); // 파라미터는 전달할 데이터 개수
bundle.putString("id", id); // key , value
petchingLoungeFragment.setArguments(bundle);
慕尼黑的夜晚无繁华
慕运维8079593
相关分类