Because I tried too much solution within 2 days, following is a one of
the solution.

layout/ad_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
</LinearLayout>




AdPreference.java

public class AdPreference extends Preference {

    public AdPreference(Context context, AttributeSet attrs, int
defStyle) {super    (context, attrs, defStyle);}
    public AdPreference(Context context, AttributeSet attrs)
{super(context, attrs);}
    public AdPreference(Context context) {super(context);}

    @Override
    protected View onCreateView(ViewGroup parent) {
        // this will create the linear layout defined in
ads_layout.xml
        View view = super.onCreateView(parent);

        // the context is a PreferenceActivity
        Activity activity = (Activity)getContext();

        // Create the adView
        AdView adView = new AdView(activity, AdSize.BANNER, "<your add
id>");

        ((LinearLayout)view).addView(adView);

        // Initiate a generic request to load it with an ad
        AdRequest request = new AdRequest();
        adView.loadAd(request);

        return view;
    }
}



add to current setting.xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/
android">

    ...

    <com.xxxx.xxxx.AdPreference android:layout="@layout/ad_layout"/>

    ...
</PreferenceScreen>




On 10月16日, 下午2時43分, TreKing <treking...@gmail.com> wrote:
> On Sat, Oct 15, 2011 at 9:35 PM, Perry168 <perry...@gmail.com> wrote:
> > From the web, I found some solution. Unluckly, I don't know why the AD
> > haven't show on the screen.
>
> If you don't even explain what solution you tried and what's not working,
> you're not really going to get much help.
>
> ---------------------------------------------------------------------------­----------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

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

Reply via email to