我想要在屏幕底部顯示固定廣告的項目列表。在列表中包含固定廣告
這是快速和骯髒的代碼,我至今(不包括廣告):
public class SoundBoard extends ListActivity {
private SoundManager mSoundManager;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.soundboard_item, CLIPS_STRINGS));
ListView lv = getListView();
mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(1, R.raw.bad_seasons);
mSoundManager.addSound(2, R.raw.friend_at_airport);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// When clicked, show a toast with the TextView text
String selection;
selection = (String) ((TextView) view).getText();
Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
if (selection == "Bad Seasons")
mSoundManager.playSound(1);
if (selection == "Friend at Airport")
mSoundManager.playSound(2);
}
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_HOME)){
finish();
}
if ((keyCode == KeyEvent.KEYCODE_BACK)){
finish();
}
return super.onKeyDown(keyCode, event);
}
static final String[] CLIPS_STRINGS = new String[] {
"Bad Seasons", "Friend at Airport"
};
}
我可能會使用AdMob SDK。這樣做的最好方法是什麼?
除了這個答案,你必須添加AdView adView =(AdView)this.findViewById(R.id.adView);和adView.loadAd(新的AdRequest());加載廣告。真棒回答謝謝! – HighLife 2011-06-04 21:27:42
沒問題,只記得標記爲答案:) – khellang 2011-06-04 21:28:28