>http://developer.android.com/guide/topics/ui/dialogs.html#ShowingADialog

There was a thread recently about how that part of the documentation
was wrong, actually. At the minimum you're going to have to replace
this line:
>builder = new AlertDialog.Builder(mContext);

With this:
builder = new AlertDialog.Builder(this);

On Nov 23, 9:24 am, Jags <[email protected]> wrote:
> yeah i referred this tutorial of oogle
>
> http://developer.android.com/guide/topics/ui/dialogs.html#ShowingADialog
>
> On Nov 23, 8:11 pm, Jags <[email protected]> wrote:
>
> > I have written below code for showing a custom dialog
>
> >         void CheckHighScore() {
>
> >                         AlertDialog.Builder builder;
> >                         AlertDialog alertDialog;
>
> >                         Context mContext = getApplicationContext();
> >                         LayoutInflater inflater = (LayoutInflater) 
> > mContext.getSystemService
> > (LAYOUT_INFLATER_SERVICE);
> >                         ViewGroup vg = (ViewGroup) 
> > findViewById(R.id.layout_root);
> >                         View layout = inflater.inflate(R.layout.mydialog,
> >                                                        vg);
>
> >                         builder = new AlertDialog.Builder(mContext);
> >                         builder.setView(layout);
> >                         alertDialog = builder.create();
>
> >                         alertDialog.show();
>
> >         }
>
> > __________
> > xml file
> > __________
>
> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > android"
> >         android:id="@+id/layout_root" android:orientation="vertical"
> >         android:layout_width="fill_parent"
> > android:layout_height="fill_parent"
> >         android:padding="10dp">
> >         <TextView android:id="@+id/desc" android:text="@string/ask_info"
> > android:layout_width="wrap_content"
> >                 android:layout_height="wrap_content" 
> > android:textColor="#FFF" />
>
> >         <EditText android:text="Enter your info here" android:id="@+id/
> > yourinfo" android:layout_width="wrap_content"
> > android:layout_height="wrap_content"></EditText>
> > </LinearLayout>
>
> > it is unable to find ViewGroup in above code and is crashing. I have
> > another main.xml file which is set to content layout in this activity.
> > So how can I correct this thing ?
>
> > Also I need to add some validation here to this dialog like info
> > cannot be empty !
>
> > thanks in advance
> > Jags

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to