0

我不知道为什么 youtube_title 和 youtube_description 为空???在我向这个editText添加文本之后???我一直这样做,为什么现在它不起作用???

是否有问题,因为它在弹出窗口中?

    public void popup_win_with_layout (){



    //select video to upload youtube

    //popup window  

    AlertDialog.Builder popupwin = new AlertDialog.Builder(this);
    LayoutInflater inflater = this.getLayoutInflater();     

     //try
    popupwin.setTitle("Y");

    popupwin.setIcon(R.drawable.ic_launcher);

    popupwin.setView(inflater.inflate(R.layout.pop_up_win, null)).setPositiveButton(getString(R.string.Continue), new DialogInterface.OnClickListener()

    {

   public void onClick(DialogInterface dialog, int id)
    {
    //Action for 'Ok' Button
       EditText youtue_title;
       EditText youtube_description;
      youtue_title=(EditText)findViewById(R.id.youtue_title); //why youtue_title is null ????? 


      youtube_description=(EditText)findViewById(R.id.youtube_description); ////why youtube_description is null ????? 

       video_title = youtue_title.getText().toString();
       video_description = youtube_description.getText().toString();
       Log.d(TAG, video_title +video_description );

       PickVideo() ; 

                    }
    });



    popupwin.show();
}
4

1 回答 1

3

代替:

youtue_title=(EditText)findViewById(R.id.youtue_title);
youtube_description=(EditText)findViewById(R.id.youtube_description);

和:

    youtue_title=(EditText)((AlertDialog)dialog).findViewById(R.id.youtue_title);
    youtube_description=(EditText)((AlertDialog)dialog).findViewById(R.id.youtube_description);
于 2013-05-19T12:05:46.540 回答