首页 \ 问答 \ 如何使数字时钟显示只有几小时和几分钟(how to make digital clock display only hours and minutes)

如何使数字时钟显示只有几小时和几分钟(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);
    }

相关问答

更多
  • 以下是实心、空心、倒立,三种等边三角形的代码: 实心等边三角形: 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 ...
  • 这是我接近它的方式。 程序一次打印一行,不能打印半行然后开始打印另一行。 话虽如此,你应该认识到三角形中的模式。 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 ...
  • 首先,你创建一个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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)