小编MrM*_*sUp的帖子

在jar之前提取文件路径

假设您使用的是任何类型的fileIO,

public class example{

    public Example(){
    File file = new File(getClass().getProtectionDomain().getCodeSource().getLocation());

    //file IO process ....
    }
}
Run Code Online (Sandbox Code Playgroud)

通过使用getClass().getProtectionDomain().getCodeSource().getLocation()你将获得"example.jar"的完整路径.那么,如何获得该文件位置但没有"example.jar"?

(实际上是jar所在的文件夹,但不是jar本身的链接)

java jar filepath

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

android EditText imeOption OnClick

使用Button很简单,

<Button 
    android:blablabla="blabla"
    ...
    android:onClick="doSomething" />
Run Code Online (Sandbox Code Playgroud)

这将执行doSomething(View)功能.

我们如何使用EditText模仿这个?我已经读过这个,我读到大多数人都使用imeOptions(这似乎仍然是必要的),然后在EditText对象上实现一个actionListener.

这是我迷路了.有没有办法从我们的键盘实现"完成"-action(或发送或...)到onClick函数,就像我们使用Button一样,或者我们是否需要显式实现监听器?

问候 !

android onclick android-edittext imeoptions

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

定时器到分钟:秒:几百秒

可能重复:
如何将毫秒转换为"hh:mm:ss"格式?

我打赌很多人需要一个计时器,包括:minutes : seconds : hundreds of seconds.显然,你开始:

` public TimeGame(){

    timer = new Timer(10, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            counter++;
        }
    });
    timer.start();
}`
Run Code Online (Sandbox Code Playgroud)

然后你需要调用一个改变这个计数器的方法:minutes : seconds : hundreds of seconds.

`private String timeTransfer(){

     minutes = counter/6000;
     counter = counter - (minutes*6000);
     seconds = counter/100 ;
     counter = counter - (seconds*100);
     milliseconds = counter;
     return minutes + " : " + seconds + " : " + miliseconds;
 }`
Run Code Online (Sandbox Code Playgroud)

但我的方法有一个错误.一旦它达到100毫秒,它就会跳回到0.通常它必须放 …

java timer

0
推荐指数
1
解决办法
4175
查看次数

标签 统计

java ×2

android ×1

android-edittext ×1

filepath ×1

imeoptions ×1

jar ×1

onclick ×1

timer ×1