ok, this worked, but i dont know what was wrong in my aproach, for the sake of meeting deadline i will use this for now
http://www.anddev.org/viewtopic.php?p=12915 in the above example, can I remove the edit text and show some scrollable text info full screen ? any helps are thanked regards On Nov 23, 10:21 pm, Jags <jag...@gmail.com> wrote: > is it because i am calling it from a handler ? > > this handler is a private member variable of my activity > > private Handler myhandler = new Handler() { > /* (non-Javadoc) > * @see android.os.Handler#handleMessage(android.os.Message) > */ > @Override > public void handleMessage(Message msg) { > switch (msg.what) { > case FINISHED: > ShowAlert(); > break; > > } > super.handleMessage(msg); > } > }; > > On Nov 23, 9:08 pm, Jags <jag...@gmail.com> wrote: > > > ok! i moved the code to onCreateDialog > > > and even tough vg is null, it created the alert. but should vg be > > null ? > > > but it crashed again ! > > > here is code > > > protected Dialog onCreateDialog(int id) { > > > AlertDialog.Builder builder; > > AlertDialog alertDialog = null; > > > Context mContext = getApplicationContext(); > > LayoutInflater inflater = (LayoutInflater) > > mContext.getSystemService > > (LAYOUT_INFLATER_SERVICE); > > > switch(id) { > > case MY_DIALOG_ID: > > > 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(); > > > break; > > > default: > > > alertDialog = null; > > } > > > return alertDialog; > > } > > > void CheckHighScore() { > > > showDialog(MY_DIALOG_ID); > > > } > > > On Nov 23, 8:26 pm, Jags <jag...@gmail.com> wrote: > > > > I understand that this is coming null because my current activity > > > layout is main.xml. but is it that i need to do a setlayout to > > > mydialog before starting any of my code ? > > > > On Nov 23, 8:11 pm, Jags <jag...@gmail.com> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en