0

사용자 지정 경고 대화 상자에서 레이아웃 매개 변수를 인식하지 못하여 null 포인터 예외가 발생했습니다.맞춤 알림 대화 상자의 레이아웃 매개 변수에 액세스하는 방법 ...?

.

그래서 어떤 사람이 이것을 알고 있으면 나를 도와주세요 ...?

미리 감사드립니다 ...!

builder = new AlertDialog.Builder(this); 
     builder.setView(getLayoutInflater().inflate(R.layout.custom_dialog, null)); 
     //AlertDialog dialog = new AlertDialog.Builder(this).create(); 
     //dialog.setContentView(R.layout.custom_dialog); 
     dialog = builder.create(); 
     customDialogList = (ListView) dialog.findViewById(R.id.custom_list); 
     customDialogList.setAdapter(customDialogAdapter); // here null pointer exception  
     dialog.setCancelable(true); 
     dialog.show(); 
+0

코드에서 가리키는 nullpointer는 어디에 있습니까? –

+0

@ coder_For_Life22 코드가 업데이트되었습니다. – Noby

답변

1
builder = new AlertDialog.Builder(this); 
     view customView = getLayoutInflater().inflate(R.layout.custom_dialog, null); 
     builder.setView(customView); 
     //AlertDialog dialog = new AlertDialog.Builder(this).create(); 
     //dialog.setContentView(R.layout.custom_dialog); 
     dialog = builder.create(); 
     customDialogList = (ListView) customView.findViewById(R.id.custom_list); 
     customDialogList.setAdapter(customDialogAdapter); 
     dialog.setCancelable(true); 
     dialog.show(); 

이 시도.

+0

그 일하는 지금 .. 고맙습니다 ...! – Noby

관련 문제