gpt4 book ai didi

android - 在列表下方包含固定广告

转载 作者:行者123 更新时间:2023-11-29 22:24:49 25 4
gpt4 key购买 nike

我希望在屏幕底部有一个带有固定广告的项目列表。

这是我目前使用的快速而肮脏的代码(还不包括广告):

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。这样做的最佳方法是什么?

最佳答案

setContentView(R.layout.soundboard); 添加到您的 onCreate 方法,然后在布局中创建两个 XML 文件:

音板.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<include layout="@layout/ad"/>
</LinearLayout>

和 ad.xml,其中将包含您的广告布局。

关于android - 在列表下方包含固定广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6239275/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com