如何使数字时钟显示只有几小时和几分钟(how to make digital clock display only hours and minutes)
我的应用程序中有一个活动的数字时钟,我想只显示小时和分钟,并且不想显示秒数。
I have a digital clock on an activity in my app and I want to display only hours and minutes on it and don't want to display seconds.
原文:https://stackoverflow.com/questions/11143568
更新时间:2022-07-02 15:07
最满意答案
首先,你创建一个Random对象,这很好!
Random randGen = new Random();
但你永远不会使用它。 相反,你调用randGen,你定义的功能
for(int i = 0; i < 3; i++) { x[i] = randGen(curWidth); y[i] = randGen(curHeight); }
但randGen定义为始终返回0! 您应该擦除该方法,并在循环调用中
for(int i = 0; i < 3; i++) { x[i] = randGen.nextInt(curWidth); y[i] = randGen.nextInt(curHeight); }
First, you create a Random object, which is good!
Random randGen = new Random();
But you never use it. Instead, you call randGen, a fuction you've defined
for(int i = 0; i < 3; i++) { x[i] = randGen(curWidth); y[i] = randGen(curHeight); }
But randGen is defined to always return 0! You should erase that method, and in your loop call
for(int i = 0; i < 3; i++) { x[i] = randGen.nextInt(curWidth); y[i] = randGen.nextInt(curHeight); }
相关问答
更多-
使用java程序用“*”打印一个三角形[2023-07-24]
以下是实心、空心、倒立,三种等边三角形的代码: 实心等边三角形: public static void main(String[] args) { int n = 5; String c = "0"; String x = "*"; for (int i = 0; i < n; i++) { for (int k = 0; k < n - i - 1; k++) { System.out.print(c); } for (int k = 0; k < i + 1; k++) { System.out.pri ... -
一个好的解决方案是从随机点开始(使用您的首选分布)并应用一些三角测量算法。 其中,Delaunay三角剖分是一个很好的候选者,因为它的计算复杂度和代码可用性都很低。 A good solution is to start with random points (with your preferred distribution) and apply some triangulation algorithm. Among these, the Delaunay triangulation is a good c ...
-
修改循环的示例 int size = 5; String print = ""; for(int i=0;i<=size;i++) { print += "*"; for(int j=size;j>i;j--) print+= (i==0)?"*":" "; print += "*\n"; } Sample modification of your loop int size = 5; String print = ""; for(int i=0;i<=size ...
-
在java中打印数字三角形(Print triangle of numbers in java)[2023-08-17]
这是我接近它的方式。 程序一次打印一行,不能打印半行然后开始打印另一行。 话虽如此,你应该认识到三角形中的模式。 1 2 6 3 7 10 4 8 11 13 5 9 12 14 15 你有第一个数字n ,然后你看到下一行以n + 1开头。 行中的下一个数字是(n + 1) + t ,其中t = 4 。 那里有一种模式。 第三行遵循相同的模式。 第一个数字是(n + 1)然后你可以用+ (t - 1)计算其他数字 这可以通过for循环完成,就像你第一次做的那样。 对于最后一个三角形,您可以使用相同的过程, ... -
如果您确定几何体是否始终是凸的,那么您真正需要的是凸壳算法。 凸壳:此算法通过仅连接3d空间中给定点集的最外侧顶点来创建网格。 显然,您将松开凸结构内部的顶点,不会在任何三角形中使用。 这仅适用于凸形。 下面是凸壳结构的一个很好的例子。 有许多库实现了Convex hulling算法。 例如:CGAL,BulletPhysics和OpenMesh。 如果您正在寻找快速建造凸壳的方法,QuickHull是最好的地方。 http://www.qhull.org What you exactly need is ...
-
P(x) = (1 - sqrt(r1)) * A(x) + (sqrt(r1) * (1 - r2)) * B(x) + (sqrt(r1) * r2) * C(x) P(y) = (1 - sqrt(r1)) * A(y) + (sqrt(r1) * (1 - r2)) * B(y) + (sqrt(r1) * r2) * C(y) 更多信息可以在这里找到math.stackexchange和这个文件 P(x) = (1 - sqrt(r1)) * A(x) + (sqrt(r1) * (1 - r2 ...
-
感谢@Phorgz&@GabeRogan指引我朝着正确的方向前进。 Delaunay Triangulation绝对是最佳选择,即使将画布更新为动画,结果也非常快速。 我最终使用了npm包更快delaunay ,它使用分而治之算法对随机生成的点进行三角测量。 以下是我在画布上绘制的结果,点随着飞机移动而更新: Thanks to @Phorgz & @GabeRogan for pointing me in the right direction. Delaunay Triangulation was de ...
-
用Java创建随机三角形(Creating random Triangles in Java)[2024-02-19]
首先,你创建一个Random对象,这很好! Random randGen = new Random(); 但你永远不会使用它。 相反,你调用randGen,你定义的功能 for(int i = 0; i < 3; i++) { x[i] = randGen(curWidth); y[i] = randGen(curHeight); } 但randGen定义为始终返回0! 您应该擦除该方法,并在循环调用中 for(int i = 0; i < ... -
我使用的阴影方法是: glShadeModel(GL_FLAT); 和你一起到目前为止。 当我渲染输出时,“法线”显示如下。 我不在乎它不计算正确的法线,但看起来两个并排三角形的法线是相同的 是的, 你通过GL_FLAT要求 : GL基元可以具有平坦或平滑的阴影。 默认情况下,平滑着色会导致计算的顶点颜色在基元被光栅化时进行插值,通常会为每个结果像素片段分配不同的颜色。 平面着色选择仅一个顶点的计算颜色,并将其分配给通过栅格化单个基元生成的所有像素片段。 如果要在所有三个顶点的法线之间进行插值,则需要使用G ...
-
你的if是缺少括号 if(j<=i) System.out.print(k+" " ); k++; 所以它总是递增k 它应该是 if(j<=i){ System.out.print(k+" " ); k++; } Your if is missing brackets if(j<=i) System.out.print(k+" " ); k++; so it always increments k it should be if(j<=i){ System.out.prin ...