问题列表 - 第37731页

默认构造函数是善还是恶?Checkstyle和PMD在这里相反

Checkstyle说:

Class should define a constructor.
Run Code Online (Sandbox Code Playgroud)

PMD说:

Avoid unnecessary constructors - the compiler will generate these for you.
Run Code Online (Sandbox Code Playgroud)

谁是对的?或者让我们这样说吧 - 在课堂上有一个空的默认ctor有哪些优点和缺点?

java checkstyle pmd

12
推荐指数
3
解决办法
6389
查看次数

IPhone核心数据模拟器

我创建了一个使用核心数据的应用程序.有没有办法在模拟器上查看sqlite db?一个工具可能允许在模拟器上查询sqlite数据库?像数据浏览器一样?

有没有办法浏览i​​phone模拟器到sqlite db位置?

sqlite iphone ios-simulator

10
推荐指数
2
解决办法
4975
查看次数

如何在OpenGL中旋转模型而不是相机?

我和标题中的qustion相同:/我做了类似的事情:

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glTranslatef(0.0f, 0, -zoom);
  glRotatef(yr*20+moveYr*20, 0.0f, 1.0f, 0.0f);
  glRotatef(zr*20+moveZr*20, 1.0f, 0.0f, 0.0f);

  //Here model render :/
Run Code Online (Sandbox Code Playgroud)

在我的应用程序相机旋转不是模型:/

opengl rotation

5
推荐指数
2
解决办法
6409
查看次数

Android:当焦点在EditText无效时,对话框会自动显示软键盘

Android:焦点在EditText上时自动显示软键盘

我已经阅读了这篇文章,它会在显示一个对话框时自动显示虚拟键盘.但是,它不适合我.任何想法为什么?虽然当对话框出现时编辑文本自动聚焦,但事件不会触发.我也读过onpostresume的答案,但我不知道如何应用它.任何帮助表示赞赏.

final Dialog dialog = new Dialog(ThesisI.this);
        dialog.setContentView(R.layout.budget_dialog);


        final EditText et = (EditText) dialog.findViewById(R.id.textComments);
        final Button enter = (Button) dialog.findViewById(R.id.buttonEnter);
        final Button cancel = (Button) dialog.findViewById(R.id.buttonCancel);

        enter.setOnClickListener(new View.OnClickListener() {
      @Override
   public void onClick(View v) {

      }
        });
        /**cancel */
        cancel.setOnClickListener(new View.OnClickListener() {
      @Override
   public void onClick(View v) {
   }
        });       
        dialog.show(); 

        et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                  dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

                }
            }
        });
Run Code Online (Sandbox Code Playgroud)

但是,我注意到如果我将焦点更改为按钮,则再次聚焦到编辑文本.此事件有效,使用下面的代码.

et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean …
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard

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

是否存在.closest()的替代方案?

这是我的代码片段:

$("#myid").append($("p:contains('text')").closest("div").clone());
Run Code Online (Sandbox Code Playgroud)

我试图获得包含'text'的p的第一个最接近的祖先div元素.

我正在寻找.closest()的替代品,因为我必须使用jquery版本1.2.6.你知道我在找什么吗?

我希望你能帮助我.我感谢每一个提示,一段代码等等.

javascript jquery

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

在uiscrollview中检测uiimageview中的水龙头

我有一个UIScrollView,其中包含多个UIImageViews.

frame = [[UIImageView alloc] initWithImage:bg];
frame.frame = CGRectMake(FRAME_SEPARATOR + numPage*1024 + numColumn*(FRAME_SEPARATOR+230), 10 +numRow*(FRAME_SEPARATOR+145), 230, 145);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
[frame addGestureRecognizer:tap];
[tap release];
[scroll addSubView:frame];
Run Code Online (Sandbox Code Playgroud)

问题是在点击图像时没有调用imageTapped.

如果我将手势识别器添加到滚动视图,如下所示:

UITapGestureRecognizer *tap =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
[scroll addGestureRecognizer:tap];
[tap release];
Run Code Online (Sandbox Code Playgroud)

imageTapped被调用.

如何检测UIImageViews上的水龙头?

谢谢

iphone sdk uiimageview

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

使用jQuery获取所有DOM元素的最佳方法

使用jQuery在页面上获取所有DOM元素的最佳方法是什么?

谢谢,

DLiKS

编辑:这适用于使用grayscale.js灰色整个页面的脚本 - http://james.padolsey.com/demos/grayscale/.jQuery,因为我可以!:P

javascript jquery jquery-selectors

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

从perl cgi :: application中的模板中分离布局

我正在使用html :: template构建一个perl cgi :: application.

我正在使用具有相同布局的7-8个不同模板 - 页眉,页脚,左列等.如何将这个html从模板文件中分离到单个布局文件中.除了cgi :: app和html :: template之外,我还需要什么perl模块.

谢谢

perl layout templates cgi

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

关于正则表达式的困惑

我刚刚在JavaScript中找到了这个正则表达式

var str=input.replace(/\0/g, "\\0");
Run Code Online (Sandbox Code Playgroud)

你能解释一下这是什么意思吗?是什么意思/\0/g\\0

javascript regex

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

线程与异步

我从这篇非常好的文章中读到了编程的线程模型与异步模型.http://krondo.com/blog/?p=1209

但是,文章提到了以下几点.

  1. 只要有I/O,异步程序就会通过在任务之间切换来超越同步程序.
  2. 线程由操作系统管理.

我记得通过在Ready-Queue和Waiting-Queue(以及其他队列之间)之间移动TCB来读取线程由操作系统管理.在这种情况下,线程不会浪费时间等待它们吗?

鉴于上述情况,异步程序相对于线程程序有什么优势?

asynchronous twisted

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