0
フラグメントビューのリストビューにadmob広告を配置します。私はこれを試みたが、それは動作しません。どのように私はそれを実装することができます。リストビューにバナー広告を表示するには、else ifを変更するにはどうすればよいですか?フラグメントのリストビューにadmob広告を配置する方法
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType(i);
if (type == 0) {
if (view == null) {
view = new EmptyCell(mContext);
}
if (i == overscrollRow) {
((EmptyCell) view).setHeight(AndroidUtilities.dp(88));
} else {
((EmptyCell) view).setHeight(AndroidUtilities.dp(16));
}
} else if (type == 1) {
if (view == null) {
view = new ShadowSectionCell(mContext);
}
} else if (type == 2) {
if (view == null) {
view = new TextSettingsCell(mContext);
}
TextSettingsCell textCell = (TextSettingsCell) view;
else if (i == languageRow) {
textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), true);
} else if (i == contactsSortRow) {
String value;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
int sort = preferences.getInt("sortContactsBy", 0);
if (sort == 0) {
value = LocaleController.getString("Default", R.string.Default);
}
} else if (i== adsRow)
{
adView = new AdView(this, AdSize.SMART_BANNER, "MY_ID");
// Set the AdListener.
adView.setAdListener(this);
// Add the AdView to the view hierarchy. The view will have no size until the ad is loaded.
RelativeLayout layout = (RelativeLayout) findViewById(R.id.home_layout);
RelativeLayout.LayoutParams adsParams =new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
adsParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout.addView(adView,adsParams);
AdRequest adRequest = new AdRequest();
// Start loading the ad in the background.
adView.loadAd(adRequest);
}