小编Paw*_*nr1的帖子

在Java中比较两个字符串

可能重复:
Java String.equals与==

我知道这是一个愚蠢的问题,但为什么这段代码不起作用.

boolean correct = "SampleText"  == ((EditText)findViewById(R.id.editText1)).getText().toString();
    if(correct) ((TextView)findViewById(R.id.textView1)).setText("correct!");
    else ((TextView)findViewById(R.id.textView1)).setText("uncorrect!");  
Run Code Online (Sandbox Code Playgroud)

关键是要检查"editText1"的内容是否等于"Sample Text"

java string android

7
推荐指数
1
解决办法
4万
查看次数

如何在LibGdx中使用Google Play游戏服务

我想在我的LibGDX And​​roid游戏中使用Google Play游戏服务API的成就和排行榜.我唯一能做的就是从Game Services开发者网站上运行示例.我一直试图在我的项目中使用这段代码很多天,我什么都没有.我也试过按照这个教程http://helios.hud.ac.uk/u1070589/blog/?p=202但我没有"主要游戏类(从ApplicationListener扩展的那个)"这是在步骤7中需要.我只有

  • 公共类DogeJump扩展了Game
  • 公共类MainActivity扩展AndroidApplication实现IActivityRequestHandler
  • 公共类BaseScreen实现了Screen
  • 公共类GameScreen扩展了负责游戏玩法的BaseScreen //

这是来自MainActivity.java的onCreate方法

    protected void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);
        thingy=this;

        RelativeLayout layout=new RelativeLayout(this);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        View gameView=initializeForView(new DogeJump(this),false);

        adView=new AdView(this,AdSize.IAB_MRECT,"ca-app-pub-XXXXXXX363095/9011689567");

        adView.loadAd(new AdRequest());

        layout.addView(gameView);
        RelativeLayout.LayoutParams adParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layout.addView(adView,adParams);       



        setContentView(layout);

        //initialize(new DogeJump(this),false);
    }
Run Code Online (Sandbox Code Playgroud)

java android libgdx google-play-games

5
推荐指数
1
解决办法
3551
查看次数

我不能在Java中使用数学方法

我需要在我的Android游戏中使用"hypot"方法,但是eclipse说没有这样的方法.这是我的代码:

import java.lang.Math;//in the top of my file
float distance = hypot(xdif, ydif);//somewhere in the code
Run Code Online (Sandbox Code Playgroud)

java math android

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

android ×3

java ×3

google-play-games ×1

libgdx ×1

math ×1

string ×1