我不知道为什么youtue_title和youtube_description为空???在我为此editText添加文本后???我一直这样做,为什么现在它不起作用? ??
是否存在问题,因为它位于popup window?
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();
}
答案 0 :(得分: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);