小编Mar*_*vel的帖子

Java以智能方式将秒转换为时间

我想创建一个库,因为我找不到一个将秒或毫秒转换成时间.我的意思是:

1)如果我有61秒,时间格式为:1:01(不是1:1)

2)如果我相当于1小时1分钟,我希望它显示相同:1:01:00

我通过以下结构实现了这一目标:

public String secondsToTime(int seconds){

    String format = "";
    int currentMinutes = 0, currentHour = 0;

    if((seconds / 60) > 0 ) {
        currentMinutes = seconds / 60;
        seconds = seconds - currentMinutes * 60;
    }
    if(currentMinutes >= 60)
    {
        currentHour = currentMinutes / 60;
        currentMinutes = currentMinutes - currentHour * 60;
    }


    if(currentHour == 0) {
        if(currentMinutes < 10 && seconds < 10)
            format = "0"+currentMinutes+":0"+seconds;
        else if(currentMinutes > 9 && seconds < 10)
            format = …
Run Code Online (Sandbox Code Playgroud)

java

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

无法在带有参数和%字符的Android SQLite中使用Like语句

原因:java.lang.IllegalArgumentException:无法绑定索引1的参数,因为索引超出范围。该语句具有0个参数。

Android不识别?字符?%

我试图做到这一点:

 String selectQuery = "SELECT * FROM config WHERE Directory Like '?%';";

 SQLiteDatabase db = this.getReadableDatabase();
 Cursor cursor = db.rawQuery(selectQuery, new String[] {parent});
Run Code Online (Sandbox Code Playgroud)

我一直在寻找解决方案,但找不到任何东西,我认为这很特别。我正在尝试这样做,因为我想使查询与Strings包含character一起使用'

也许有同样问题的人可以回答我,我该如何解决。

sql sqlite android

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

Inno Setup - 如何设置安装文件夹的权限

我正在使用Inno Setup来创建我的应用程序的安装程序.

在第一次运行时,我的应用程序正在创建一个SQLite数据库,但是当用户没有修改安装文件夹的权限时,它无法实现.

我设法设置文件的权限:

[Files]
Source: "D:\....\***.jar"; DestDir: "{app}"; Flags: ignoreversion; Permissions: users-full
Source: "D:\....\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;\
    Permissions: users-full
Run Code Online (Sandbox Code Playgroud)

但这没有用,因为我需要安装文件夹的完全用户权限,例如: C:\Program Files\InstallationFolder

permissions inno-setup

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

Android RecyclerView滚动到以编程方式无法正常工作

我正在尝试以编程方式滚动到我的位置RecyclerView,这是我尝试过的,直到现在我的情况没有任何效果:

        musicList.getLayoutManager().smoothScrollToPosition(musicList, null, position);

        musicList.scrollToPosition(position);

        mLayoutManager.scrollToPosition(position);

        musicList.getLayoutManager().scrollToPosition(position);
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

我有一个已LinearLayoutManager mLayoutManager;定义并将其设置RecyclerView为:

    mLayoutManager = new LinearLayoutManager(this);
    musicList.setLayoutManager(mLayoutManager);

RecyclerView XML:

<android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/musicList"
                android:scrollbars="vertical"
                android:scrollbarThumbVertical="@drawable/custom_scrollbar_vertical"/>
Run Code Online (Sandbox Code Playgroud)

android

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

ExoPlayer上的Android流

我试图MediaPlayer转而支持ExoPlayer但我找不到任何更新的演示如何使用它.我认为他们已经删除了该FrameworkSampleSource方法.我从Github下载了演示但是我找不到播放器的实现,我可以找到添加URL的Samples对象.我有一个我想要播放的URL列表.我正在切换到ExoPlayer,因为它比MediaPlayer更顺畅.我已经阅读了有关ExoPlayer的所有StackOverflow主题,但没有更新它们.

任何人都可以举例说明如何实现它?谢谢.

android exoplayer

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

更改布局的高度平滑

我已经搜索并尝试了一些如何使用平滑动画更改视图高度的方法.我找到并且最方便的最简单的方法就是这个:

 ScaleAnimation scaleAnimation = new ScaleAnimation(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
                                mainLayout.getMeasuredHeight(), mainLayout.getMeasuredHeight() - mediaController.getMeasuredHeight() - conv.toPixels(20),
                                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                        musicListLayout.setAnimation(scaleAnimation);
                        musicListLayout.startLayoutAnimation();
Run Code Online (Sandbox Code Playgroud)

但是这种方法不起作用,我不知道为什么.我已经尝试了一些,但我想让这个工作或找到另一个.

我有一个播放列表,( WRAP_CONTENT, WRAP_CONTENT )当我播放我播放的歌曲MediaController时,我想翻译/动画,RecyclerViewMediaController改变它们的尺寸以适应屏幕.

谢谢您的帮助.

android

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

Android用自定义drawable选择器替换复选框样式

我试图用以下内容创建一个xml选择器:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/shuffleon" android:state_checked="true" />
    <item android:drawable="@drawable/shuffleoff" android:state_selected="false" />
</selector>
Run Code Online (Sandbox Code Playgroud)

当我尝试设置backgroundDrawablecheckBox复选框不更换CheckBox款式太:

  shuffle.setBackground(android.support.v4.content.res.ResourcesCompat.getDrawable(getResources(), R.drawable.shuffle, null));
Run Code Online (Sandbox Code Playgroud)

关注这个问题:为Checkbox for Android更改已选中和未选中的图标我需要设置button drawable我的xml:android:button="@drawable/checkbox"但我不能这样做,因为我正在以CheckBox编程方式创建.有没有办法如何实现这一目标?

checkbox android

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

Javascript加密在POST之前传递

我按下提交按钮时尝试加密密码.

我不明白为什么密码输入的值没有改变,ecryption正确完成.

<script>
    function cript(){
        var pass = CryptoJS.SHA1("<?php echo $_POST["password"]; ?>");

        var passString = pass.toString();

        console.log(passString);
        document.getElementById('inputPassword').value = passString;
    }
</script>
Run Code Online (Sandbox Code Playgroud)

并在HTML表单上:

<input type="submit" class="btn btn-primary" value="Proceed" onclick="cript()">
Run Code Online (Sandbox Code Playgroud)

谁能告诉我解决方案?

html javascript encryption

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

Glide 在 recyclerview 中加载相同的图像

以前没有发生在我身上,我正在努力弄清楚。

我正在尝试在RecyclerView. 图像每次都应该是随机的,我使用以下服务:https://picsum.photos/200/200/?random

但是,当我加载应用程序时,它RecyclerView会一遍又一遍地显示相同的图像。

为了清楚起见,我清除了持有人:

        Glide.with(context).clear(holder.view.avatar)
        holder.view.image.setImageDrawable(null)
Run Code Online (Sandbox Code Playgroud)

然后加载它

        Glide.with(context)
                .load("https://picsum.photos/200/200/?random")
                .into(holder.view.avatar)
Run Code Online (Sandbox Code Playgroud)

知道会有什么问题吗?

android android-glide

-1
推荐指数
1
解决办法
735
查看次数