我将数据填充到Dialog中的recyclerview中。 当我点击它时多次打开对话框,项目数量。
首先,我认为我已将对话框置于for循环中,但我没有。
final List<getterInterests> listInterests = new ArrayList<>();
pullData data1 = new pullData(Profil.this);
data1.getData("", "8", new VolleyCallback() {
@Override
public void onUserExists(String[] result) {
for(String res : result){
getterInterests getterInterests = new getterInterests(res);
listInterests.add(getterInterests);
}
Dialog dialogInterests = new Dialog(Profil.this);
dialogInterests.setContentView(R.layout.dialog_interests);
InterestsAdapter interestsAdapter = new InterestsAdapter(Profil.this,listInterests);
final RecyclerView recyclerViewInterests = dialogInterests.findViewById(R.id.recyclerViewInterests);
recyclerViewInterests.setLayoutManager(new GridLayoutManager(Profil.this,3));
recyclerViewInterests.setItemAnimator(new DefaultItemAnimator());
recyclerViewInterests.setAdapter(interestsAdapter);
dialogInterests.show();
}
@Override
public void OnSuccess() {
}
@Override
public void OnError(String ErrorMessage) {
Toast.makeText(Profil.this, ErrorMessage, Toast.LENGTH_SHORT).show();
}
});