Как получить доступ к параметрам макета для Custom Alert Dialog ...? - PullRequest
0 голосов
/ 11 октября 2011

Я получаю исключение нулевого указателя,

из-за того, что не удалось распознать параметр макета в настраиваемом диалоговом окне предупреждения.

Итак, если кто-нибудь знает это, пожалуйста, помогите мне ...?1005 *

Заранее спасибо ...!

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();

1 Ответ

1 голос
/ 11 октября 2011
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();

попробуйте это.

...