在 customDialogBox 上获取 java.lang.NullPointerException

Getting java.lang.NullPointerException on customDialogBox

我得到了这个方法的 java.lang.NullPointerException。我检查了适配器,列表很好,列表当然在 fragment_phonelist xml 文件下。

    private void showCustomDialog() {

    final Dialog dialog = new Dialog(SetupProfile.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.fragment_phonelist);

    Button done = (Button)dialog.findViewById(R.id.btn_done);
    Button canCel = (Button)dialog.findViewById(R.id.btn_cancel);
    ListView PhoneListView = (ListView)findViewById(R.id.list_phone);

   MyCustomAdapter tst = new MyCustomAdapter(this,ContactName,ContactNumb);
   PhoneListView.setAdapter(tst);

    done.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            dialog.dismiss();

        }
    });
    canCel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            dialog.dismiss();
        }
    });

    dialog.show();
}

请帮忙..

这一行

ListView PhoneListView = (ListView)findViewById(R.id.list_phone); 

不应该是这样吗:

ListView PhoneListView = (ListView)dialog.findViewById(R.id.list_phone);