views:

5075

answers:

2

Posted: Thu Jul 30, 2009 6:09 pm Post subject: How to show small View?
I need a little help from people with expirience. I hope it's easy. I just want to show new View (creating it without XML layouts) above main program's view. It's to integrate AdMob.com ad block:

I wrote such code:

AdView ad = new AdView(this); 
ad.layout(10, 10, 100, 100); 
ad.setVisibility(View.VISIBLE); 
ad.bringToFront(); 
ad.requestFocus(); 
ad.invalidate();

As you see - nothing helped, no window visible
What do I make incorrectly? Thanks!

P.S. I made in in Activity's onCreate(Bundle), but I tried in other locations too.

+4  A: 

You haven't actually told the system to draw anything or where to draw it. You'll want to look at the documentation for setContentView(view) on your Activity. If you're trying to get this to draw over your current screen, look at the documentation for Dialog (and setContentView).

When I'm programmatically creating arbitrary views to draw within an existing layout, I usually add a FrameLayout tag to my layout XML, then in the code call findViewById(), then I can use that FrameLayout view to add the view to (addView()).

I hope that helps some without writing your code for you.

lilbyrdie
Thank you for your reply.I already solved problem remaking all application with XML and using RelativeLayout or AbsoluteLayout.
A: 

Hi... I too got stuck with the same problem. Can u explain me how did u solve ur problem.... please....

Thanks in advance,

As I said - I made all with xml layout. <com.admob.android.ads.AdView android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" admobsdk:backgroundColor="#0f0f00" admobsdk:textColor="#FFFFFF" admobsdk:keywords="... .... ..." admobsdk:testing="false" />
Thanks for the reply... Did u make ur own package..??? What are the inputs you are taking from the user...???Please explain me clearly....