布局
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:orientation="horizontal"
android:paddingRight="2dp" >
<View
android:id="@+id/main_v_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top" >
</View>
</LinearLayout>
</LinearLayout>
代码
private View infoView;
infoView = (View) findViewById(R.id.main_v_logo);
infoView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(activity.getResources().getString(R.string.url)));
startActivity(intent);
}
})
url就是网址。点击直接进入的广告
还有一个
adview聚合平台
布局
<LinearLayout
android:id="@+id/adContainer"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content" />
代码
public static boolean isLite = true;
LinearLayout adContainer = (LinearLayout) findViewById(R.id.adContainer);
if (isLite) {
adView = new AdView(this, AdSize.BANNER, AD_UNIT_ID);
adContainer.addView(adView);
adView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);
} else {
((LinearLayout) adContainer.getParent()).removeView(adContainer);
}
}