我只是想让我的活动中的音乐无休止地播放(即当我的38秒音乐结束时,我想一次又一次地播放它直到用户离开页面).顺便说一下,我正在使用MediaPlayer.
ourSound = MediaPlayer.create(NewKFCActivity.this, R.raw.start);
ourSound.start();
Run Code Online (Sandbox Code Playgroud)
干杯!
我今天正在阅读很多关于此的主题.但是,我见过的所有解决方案都无法成为我的解决方案.我是Android开发的新手.我的问题是我的主页面上有两个按钮 - 即PlayGame和Help.PlayGame onClicked()将引导用户进入"难度页面",用户可以选择"简易","中等"或"硬"模式.我想要的是,当用户按下"难度页面"中的Android后退按钮时,它将返回主菜单(即可以看到PlayGame和帮助的位置),因为在我的情况下发生的是它回到Android菜单.我完成了我的活动,如下所示,我在我的两个按钮(帮助和PlayGame)中尝试了不同的方法,但没有给我任何运气.
这是我的主菜单.
package com.kfc;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
public class NewKFCActivity extends Activity {
/** Called when the activity is first created. */
ImageButton bPlay, bHelp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
bPlay = (ImageButton) findViewById(R.id.playGame);
bPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(v.getContext(), SelectDifficulty.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
NewKFCActivity.this.startActivity(intent);
}
});
bHelp = (ImageButton) findViewById(R.id.Help);
bHelp.setOnClickListener(new View.OnClickListener() …Run Code Online (Sandbox Code Playgroud) 我只是想模仿像愤怒的小鸟这样的著名游戏,当你开始游戏时,有几个屏幕,闪烁然后淡出,然后转到另一个屏幕,淡出然后出现主菜单。我怎么做?目前我的代码是淡入淡出。在实现下面的代码后,令人惊讶的是,它没有动画。有什么想法吗?
package com.kfc;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.*;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Intro extends Activity {
LinearLayout screen;
Handler handler = new Handler();
int i;
Intent intent;
TextView tv;
Animation mAnim;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.introxml);
screen = (LinearLayout) findViewById(R.id.myintro);
Animation fade = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
fade.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在横向模式下开发一个应用程序,所以我在我的Manifest中放置了"android:screenOrientation ="landscape.它工作得很好,但是,我的xml文件的图形布局仍然没有处于横向模式,所以我无法设计我的用户界面很好.有什么帮助吗?谢谢
我只是在Eclipse Android中完成了类似Mastermind的游戏应用程序.我现在想要的是让用户在他/她的Facebook帐户上发布他/她的分数.在AlertDialog构建器中,当用户选择"发布到我的Facebook"按钮时,它应该能够真正做到.实际代码非常感谢!
干杯
可能重复:
O(1)中的唯一随机数?
我是Java新手.我想从给定的集合中生成一组随机数,并且数字也必须不重复.例如,可能的数字是[0,1,2,3],我想获得存储在数组中的三个随机唯一数字.防爆.[0,2,1], [2,3,1], [0,3,2]等等