我想向DialogFragment发送一些数据,但是在发送数据后我不想更改屏幕。我正在尝试通过Bundle进行操作,但是在打开DialogFragment时收到错误消息。
我在主要片段的onCreateView中具有以下功能:
private void getParticipant(){
ArrayList<ParticipantGroup> participants = participantResponse.getParticipants();
for (int i = 0; i <participants.size() ; i++) {
if(participants.get(i).getId_user()==user.getUser().getId()){
participant =participants.get(i);
AdapterMarket.BidKaratekaDialogFragment bidKaratekaDialogFragment = new AdapterMarket.BidKaratekaDialogFragment();
Bundle args = new Bundle();
args.putInt("participant", participant.getId());
bidKaratekaDialogFragment.setArguments(args);
}
}
}
这是DialogFragment,我在其中接收OnCreateView中的数据:
Bundle mArgs = getArguments();
int participantInGroup = mArgs.getInt("participant", 0);
我收到此错误:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String, int)' on a null object reference
at com.example.karate_manager.Adapters.AdapterMarket$BidKaratekaDialogFragment.onCreateDialog(AdapterMarket.java:177)