idan
idan

Reputation: 2170

EditText.getText in popup window dialog

i dont know why youtue_title and youtube_description is null ??? after i add text to this editText ??? i do this all the time why now it not work ? ??

Is there a problem because it is in a 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();
}

Upvotes: 0

Views: 314

Answers (1)

Mohamed_AbdAllah
Mohamed_AbdAllah

Reputation: 5322

Replace:

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

with:

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

Upvotes: 3

Related Questions