当用户点击Button我的应用程序(在a中打印SurfaceView)时,我想要Dialog显示一个文本,我想将结果存储在一个String.我希望文本Dialog覆盖当前屏幕.我怎样才能做到这一点?
在简要介绍一下Google后,我发现这个链接描述了差异,但从语法的角度来看.
在编程场景中何时优先于另一个?
我有以下代码:
public class Test {
public static void main(String[] args) {
Integer alpha = new Integer(1);
Integer foo = new Integer(1);
if(alpha == foo) {
System.out.println("1. true");
}
if(alpha.equals(foo)) {
System.out.println("2. true");
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出如下:
2. true
Run Code Online (Sandbox Code Playgroud)
但是,更改Integer objectto 的类型int将产生不同的输出,例如:
public class Test {
public static void main(String[] args) {
Integer alpha = new Integer(1);
int foo = 1;
if(alpha == foo) {
System.out.println("1. true");
}
if(alpha.equals(foo)) {
System.out.println("2. true");
}
}
}
Run Code Online (Sandbox Code Playgroud)
新输出:
1. …Run Code Online (Sandbox Code Playgroud) 无论如何我可以将List变量保存到Androids手机的内部或外部存储器中吗?我知道我可以保存原始数据,但不确定这个.
提前致谢.
我有以下代码.
this.getGame().getGraphics().drawBitmap(Assets.playScreen_LaserBeamAnimation, new Rect(0, 0, 100, 750), new Rect(0, 0, 100, 750), null);
this.getGame().getGraphics().drawBitmap(Assets.playScreen_LaserBeamAnimation, new Rect(0, 200, 10, 800), new Rect(0, 0, 200, 600), null);
Run Code Online (Sandbox Code Playgroud)
第一个render语句0.6 - 1 second用于渲染.第二个围绕着1 millisecond.
位图很大:968 KB并加载以下代码:
public Bitmap readAssetsBitmap(String filename) throws IOException {
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeStream(assets.open(filename), null, options);
if(bitmap == null) {
WSLog.d(Game.GAME_ENGINE_TAG, this,"File cannot be opened: It's value is null");
throw new IOException("File cannot be opened: …Run Code Online (Sandbox Code Playgroud) 我正在努力在其中心周围绘制一个旋转位图,并在不调整位图大小的情况下进行旋转.我正在通过游戏线程将所有精灵绘制到屏幕上,所以我正在寻找一种包含原始位图而不是画布的解决方案.
提前致谢.
到目前为止,这是我的代码,它围绕其中心转换位图,然后调整它的大小.
i = i + 2;
transform.postRotate(i, Assets.scoresScreen_LevelStar.getWidth()/2, Assets.scoresScreen_LevelStar.getHeight()/2);
Bitmap resizedBitmap = Bitmap.createBitmap(Assets.scoresScreen_LevelStar, 0, 0, Assets.scoresScreen_LevelStar.getWidth(), Assets.scoresScreen_LevelStar.getHeight(), transform, true);
game.getGraphics().getCanvasGameScreen().drawBitmap(resizedBitmap, null, this.levelStar.getHolderPolygons().get(0), null);
Run Code Online (Sandbox Code Playgroud)
更新:
我注意到这并不像听起来那么容易.我的旋转代码不是问题.位图旋转,但是dst rect也必须根据旋转角度增加/减少,否则bimap会显得更小,因为它被绘制到固定的dst rect中.所以我猜我必须开发一些会返回dst rect的方法. 所以旋转位图所需的方法没有出现调整大小:
public static Bitmap rotateBitmap(Bitmap bitmap, int rotation) // I've got this method working
Run Code Online (Sandbox Code Playgroud)
和
public static Rect rotateRect(Rect currentDst, int rotation) // Don't got this
Run Code Online (Sandbox Code Playgroud)
我明白这需要一些数学(触发),任何人都可以接受挑战吗?:P
我在思考,玩一些代码。我在Thread类遇到下列方法来:checkAccess()。
该文档(从字面上看)说“什么都不做”。如果什么都不做,那为什么会出现在Thread类中呢?-我们可能会与开发者巨魔打交道吗?
屏幕截图:

我有以下代码:
int i = (int) 0.72;
System.out.println(i);
Run Code Online (Sandbox Code Playgroud)
产生以下输出:
0
Run Code Online (Sandbox Code Playgroud)
我想象变量i应该具有值1 (因为0.72> 0.5 => 1),为什么不是这种情况?
(我想,当转换为int时,它只是在逗号之后删除十进制数字,而不是考虑到舍入;所以我可能必须自己处理它?)
我目前正在做一个项目,我想使用Android手机中的振动马达。
我想通了,在清单中设置正确的权限并获取振动器的实例:
Vibrator v = (Vibrator) game.getSystemService(Context.VIBRATOR_SERVICE);
Run Code Online (Sandbox Code Playgroud)
会给我访问权限。据我所知,使其振动的唯一方法是:
公共抽象空隙振动(长毫秒)
和
公共抽象无效振动(long []模式,int重复)
但是我想控制振动的力量:
如何控制振动的力量?
更新:
难道不应该通过改变电压(或直流PWM)来控制速度吗?
出于好奇,我来写下面的方法:
public Object getObject() {
return this.getObject();
}
Run Code Online (Sandbox Code Playgroud)
为什么Java允许我写这个?这种方法永远不会返回任何Object并导致a StackOverflow Error.