问题列表 - 第35812页

调用TextView.setText()会定期导致UI抖动

我正在编写一个音频播放器,其中一个线程每250毫秒更新一次表示轨道经过时间的TextView.

显示如下:

1:30/2:30 <-----进度条----->

TextView 1是1:30 /,TextView 2是2:30.

两者都设置为wrap_content for width.

会发生的是,在每250毫秒的周期中,线程会检查当前时间并更新TextView 1.在这短暂的时间内,TextView 2和进度条会瞬间向右推动约2-4个像素.然后他们回到原地,直到下一个周期发生同样的事情.

我不知道发生了什么.没有尾随空格字符等等,从理论上讲,一切都应该顺利进行,但事实并非如此.

谁能帮我吗?我希望别人可能遇到类似的问题....

PS:我在布局XML文件中将TextView 1初始化为0:00 /和TextView 2到0:00,代码从那里处理它.

android textview settext

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

如何减少App(.apk)大小

救命!

当我在手机上安装我的应用程序进行测试时,它显示为一个巨大的大小,11.35 MB.这是一个非常简单的应用程序,允许用户浏览有趣的事实.我能想到的唯一原因是,drawable中有14个JPEG文件作为fun-facts的背景图像.它们的平均大小约为500 KB.

我想调整我的应用程序的大小,以免耗尽用户设备上的宝贵资源.除了摆脱图片,有没有办法优化apk文件的大小?

编辑:图片是我使用Android手机拍摄的照片.

android

45
推荐指数
6
解决办法
6万
查看次数

整数不会增加?

好吧,所以我正在进行客户端/服务器测试,我将Integer playerID传递给一个线程,它将int值赋给一个简单的Player对象,而不是将playerID增加1.

 public static void main(String[] args) throws IOException {

        Vector<Player> player = new Vector<Player>();

        SlickServer ss = new SlickServer();
        ss.setVisible(true);

        ServerSocket serverSocket = new ServerSocket(4444);
        boolean listening = true;

        Integer playerID = new Integer(0);

        while(listening){
            ss.textArea.append("Waiting to connect with player: " + playerID.intValue()  + "\n");
            new ClientThread(serverSocket.accept(), player, playerID, ss.textArea).start();
            ss.textArea.append("Waiting to connect with player: " + playerID.intValue() + "\n");
        }

        serverSocket.close();
        System.exit(0);
    }
Run Code Online (Sandbox Code Playgroud)

这是在线程中增加它的地方:

public ClientThread(Socket acceptedSocket, Vector<Player> players, Integer playerID, JTextArea textArea){
        super("ClientThread");
        this.acceptedSocket = acceptedSocket;
        this.players …
Run Code Online (Sandbox Code Playgroud)

java networking multithreading integer

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

如何检查sql developer中的编译器日志?

我收到此错误:

错误:检查编译器日志

如何在Oracle SQL Developer中看到编译器日志?

logging oracle-sqldeveloper

40
推荐指数
3
解决办法
10万
查看次数

覆盖javascript中的全局函数

我试图将自己的错误处理添加到JavaScript setTimeout函数.以下代码在chrome中工作正常:

var oldSetTimeout = window.setTimeout;
window.setTimeout = function setTimeout(func, delay) {
    var args = Array.prototype.slice.call(arguments, 0);
    args[0] = function timeoutFunction() {
        var timeoutArgs = Array.prototype.slice.call(arguments, 0);
        try {
            func.apply(this,timeoutArgs);
        }
        catch (exception) {
            //Do Error Handling
        }
    }
    return oldSetTimeout.apply(this, args);
}
Run Code Online (Sandbox Code Playgroud)

但在IE7中它变成了一个递归函数.由于某种原因oldSetTimeout设置为新功能.

有什么建议?



旁注:是的,我需要这样做.我正在使用一堆第三方库,所有这些库都不能很好地处理setTimeout,所以我不能只是将调用更改为setTimeout.

javascript overriding global settimeout

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

如何查找表格单元格是否包含xx

我正在寻找创建一个jQuery逻辑来回答:

是否有任何表格单元格不包含''或'xx'且没有'yy'类

这是我的努力 - 但它似乎非常混乱?:

$('td').filter(function(index) {
            return  !$(this).hasClass('yy') &&
                    !($(this).html().trim() == '' || $(this).html().trim() == '');
        })
Run Code Online (Sandbox Code Playgroud)

jquery

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

eclipse中有一个选项,比如jsp文件的netbeans中的"view servlet"吗?

如果你在netbeans中工作,你几乎知道jsp文件中的上下文菜单条目"view servlet".它的作用是向您展示jsp生成的servlet java代码.

日食中有类似的东西吗?

java eclipse jsp web-applications

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

C#职位问题

我已经在VB中使用了以下代码,想将它用于c#中,我认为我没错,但是当我点击事件时,它只需要我记录#2,我的表中有几条记录.

private void pictureBox2_Click(object sender, EventArgs e)
{
    sF1411BindingSource.Position = +1;
}
Run Code Online (Sandbox Code Playgroud)

当我回击时也一样.例如,如果我在记录12上,我点击事件并点击第1条记录.我是一个Vb的家伙,我想在这里教自己,所以也许我在寻找一些东西.

private void pictureBox1_Click(object sender, EventArgs e)
{
    sF1411BindingSource.Position = -1;
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

c#

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

Numpy/Python与Matlab相比表现非常糟糕

新手程序员在这里.我正在编写一个程序来分析点(单元格)的相对空间位置.程序从数组中获取边界和单元格类型,第1列中的x坐标,第2列中的y坐标和第3列中的单元格类型.然后,它会检查每个单元格的单元格类型以及与边界的适当距离.如果它通过,则计算它与阵列中每个其他单元格的距离,如果距离在指定的分析范围内,则将其添加到该距离的输出数组.

我的单元格标记程序是在wxpython中,所以我希望在python中开发这个程序并最终将它粘贴到GUI中.不幸的是,现在python在我的机器上运行核心循环需要大约20秒,而MATLAB可以执行~15循环/秒.由于我计划在大约30个案例中对几个探索性分析类型进行1000次循环(具有随机比较条件),这不是一个微不足道的差异.

我尝试运行一个分析器,数组调用是1/4的时间,几乎所有其余的都是未指定的循环时间.

这是主循环的python代码:

for basecell in range (0, cellnumber-1):
    if firstcelltype == np.array((cellrecord[basecell,2])):
        xloc=np.array((cellrecord[basecell,0]))
        yloc=np.array((cellrecord[basecell,1]))
        xedgedist=(xbound-xloc)
        yedgedist=(ybound-yloc)
        if xloc>excludedist and xedgedist>excludedist and yloc>excludedist and    yedgedist>excludedist:
            for comparecell in range (0, cellnumber-1):
                if secondcelltype==np.array((cellrecord[comparecell,2])):
                    xcomploc=np.array((cellrecord[comparecell,0]))
                    ycomploc=np.array((cellrecord[comparecell,1]))
                    dist=math.sqrt((xcomploc-xloc)**2+(ycomploc-yloc)**2)
                    dist=round(dist)
                    if dist>=1 and dist<=analysisdist:
                         arraytarget=round(dist*analysisdist/intervalnumber)
                         addone=np.array((spatialraw[arraytarget-1]))
                         addone=addone+1
                         targetcell=arraytarget-1
                         np.put(spatialraw,[targetcell,targetcell],addone)
Run Code Online (Sandbox Code Playgroud)

这是主循环的matlab代码:

for basecell = 1:cellnumber;
    if firstcelltype==cellrecord(basecell,3);
         xloc=cellrecord(basecell,1);
         yloc=cellrecord(basecell,2);
         xedgedist=(xbound-xloc);
         yedgedist=(ybound-yloc);
         if (xloc>excludedist) && (yloc>excludedist) && (xedgedist>excludedist) && (yedgedist>excludedist);
             for comparecell = 1:cellnumber;
                 if secondcelltype==cellrecord(comparecell,3);
                     xcomploc=cellrecord(comparecell,1);
                     ycomploc=cellrecord(comparecell,2);
                     dist=sqrt((xcomploc-xloc)^2+(ycomploc-yloc)^2);
                     if (dist>=1) && (dist<=100.4999);
                         arraytarget=round(dist*analysisdist/intervalnumber); …
Run Code Online (Sandbox Code Playgroud)

python matlab numpy

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

而(1)Vs. for while(True) - 为什么会有区别?

这个关于perl中无限循环的问题很感兴趣:while(1)vs.for(;;)有速度差吗?,我决定在python中运行类似的比较.我期望编译器会为while(True): pass和生成相同的字节代码while(1): pass,但实际上并非python2.7中的情况.

以下脚本:

import dis

def while_one():
    while 1:
        pass

def while_true():
    while True:
        pass

print("while 1")
print("----------------------------")
dis.dis(while_one)

print("while True")
print("----------------------------")
dis.dis(while_true)
Run Code Online (Sandbox Code Playgroud)

产生以下结果:

while 1
----------------------------
  4           0 SETUP_LOOP               3 (to 6)

  5     >>    3 JUMP_ABSOLUTE            3
        >>    6 LOAD_CONST               0 (None)
              9 RETURN_VALUE        
while True
----------------------------
  8           0 SETUP_LOOP              12 (to 15)
        >>    3 LOAD_GLOBAL              0 (True)
              6 JUMP_IF_FALSE            4 (to 13)
              9 POP_TOP             

  9          10 JUMP_ABSOLUTE            3
        >>   13 POP_TOP …
Run Code Online (Sandbox Code Playgroud)

python

110
推荐指数
3
解决办法
7万
查看次数