// Start of code for PopupWindow
PopupWindow popupWindow = new
PopupWindow(context);  ....................Line 1
TextView textView = new
TextView(context); ............................................Line 2
popupWindow.setContentView(textView);
LayoutParams layoutParams = new
LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
textView.setLayoutParams(layoutParams);
textView.setText("My text goes here");
popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
// End of code for PopupWindow

Thanks Mukesh and Jovish for your reply.
finally got the solution to make above Popupwindow work.
Line 1 constructs the PopupWindow (from API doc)

public PopupWindow (Context context)
Since: API Level 1
Create a new empty, non focusable popup window of dimension (0,0).
The popup does provide a background.

>> constructs a PopupWindow of dimension 0,0 ...so here we need to set the 
>> width and height as below
popupWindow.setWidth(400);
popupWindow.setHeight(180);



On Nov 26, 12:39 am, Jovish P <[email protected]> wrote:
> // Start of code for PopupWindow
> PopupWindow popupWindow = new PopupWindow(context);
> TextView textView = new TextView(context);
> popupWindow.setContentView(textView);
> LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
> LayoutParams.WRAP_CONTENT);
> textView.setLayoutParams(layoutParams);
> textView.setText("My text goes here");
> *popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);     ?????????????   *
> *
> *
> * *
> *I think you have to give  textView instead of v in this line of code.*
> // End of code for PopupWindow
>
> On Fri, Nov 25, 2011 at 5:01 PM, Mukesh Srivastav <[email protected]>wrote:
>
>
>
> > I am sure, the problem must with the context.
>
> > Any ways, for the popupwindow, you could always go with the AlertDialog,
> > it will also work as popup.
>
> > On Fri, Nov 25, 2011 at 4:57 PM, Shajahan <[email protected]> wrote:
>
> >> its not working...:(
> >> looking for some help
>
> >> On Nov 25, 4:20 pm, Mukesh Srivastav <[email protected]> wrote:
> >> > Let use know, if it works.
>
> >> > Warm Regards,
> >> > *Mukesh Kumar*,
> >> > Android Consultant/Freelancer,
> >> > India,Hyderabad.
>
> >> > On Fri, Nov 25, 2011 at 4:43 PM, Shajahan <[email protected]> wrote:
> >> > > Hi Mukesh,
>
> >> > > Thanks for the reply.
>
> >> > > am doing the same
> >> > > Context context = this;
>
> >> > > On Nov 25, 4:04 pm, Mukesh Srivastav <[email protected]> wrote:
> >> > > > Code looks fine but the problem would be with context.
>
> >> > > > do the following.
>
> >> > > > 1.create a context class variable. some thing like this.
> >> > > >    Context parentcontext;
>
> >> > > > 2.Assign this in the onCreate Method.
>
> >> > > >     parentcontext = this;
>
> >> > > > 3. then pass the parentcontext to the popupwindow
>
> >> > > >   or The another solution would be
>
> >> > > > use getParentContext(), Might helps.
>
> >> > > > On Fri, Nov 25, 2011 at 4:29 PM, Shajahan <[email protected]>
> >> wrote:
> >> > > > > I need to show the information about the field in an activity. For
> >> > > this i
> >> > > > > have created a buton and placed next to the field.
> >> > > > > Now when wants to know abt this field, he can click on that
> >> button and
> >> > > get
> >> > > > > the info.
> >> > > > > I am trying for PopupWindow. i have placed my code on the onClick
> >> event
> >> > > > > of the button
>
> >> > > > > // Start of code for PopupWindow
> >> > > > > PopupWindow popupWindow = new PopupWindow(context);
> >> > > > > TextView textView = new TextView(context);
> >> > > > > popupWindow.setContentView(textView);
> >> > > > > LayoutParams layoutParams = new
> >> LayoutParams(LayoutParams.WRAP_CONTENT,
> >> > > > > LayoutParams.WRAP_CONTENT);
> >> > > > > textView.setLayoutParams(layoutParams);
> >> > > > > textView.setText("My text goes here");
> >> > > > > popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
> >> > > > > // End of code for PopupWindow
>
> >> > > > > But the above doent help in showing the PopupWindow.
>
> >> > > > > --
> >> > > > > 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
>
> >> > > > --
> >> > > > Warm Regards,
> >> > > > *Mukesh Kumar*,
> >> > > > Android Consultant/Freelancer,
> >> > > > India,Hyderabad.- Hide quoted text -
>
> >> > > > - Show quoted text -
>
> >> > > --
> >> > > 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-Hide quoted
> >> text -
>
> >> > - Show quoted text -
>
> >> --
> >> 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
>
> > --
> > Warm Regards,
> > *Mukesh Kumar*,
> > Android Consultant/Freelancer,
> > India,Hyderabad.
>
> >  --
> > 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- Hide quoted text -
>
> - Show quoted text -

-- 
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