问题列表 - 第33311页

当startActivityForResult处于活动状态时,如何处理后退按钮?

我有一个简单的表单,用户可以从列表中添加,编辑和删除人员.当用户选择编辑某个人时,它会执行startActivityForResult,以便在编辑完成后进行相应的更改并刷新列表.如果用户从编辑屏幕单击后退按钮,则会出现强制关闭错误.

我认为这与系统期望结果有关,而且我没有正确地捕获它.我如何捕获此错误?

这是当前的onActivityResult代码:


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
 super.onActivityResult(requestCode, resultCode, intent);
 Bundle extras = intent.getExtras();
 switch(requestCode) {
 case ACTIVITY_CREATE:
  String person = extras.getString("person");
  mDbHelper.addPerson(person);
  fillData();
  break;
 case ACTIVITY_EDIT:
  Long rowId = extras.getLong("_id");
  if (rowId != null) {
   String editPerson = extras.getString("person");
   mDbHelper.updatePerson(rowId, editPerson);
  }
  fillData();
  break;
 }
}
Run Code Online (Sandbox Code Playgroud)

感谢您的任何帮助.

android

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

如何在 Mac 上的 Safari、Chrome 中获得最小高度

我有一个带有以下 CSS 的页面,它在 IE 和 FF 上呈现良好,但在 Safari 和 Chrome 中的 Mac 上,min-height 似乎不起作用,并且当浏览器页面很短时,所有内容都折叠在一起保持扩展并提供滚动条:

<style type="text/css">
    html, body {
   height: 100%;
        width: 100%;
    }
    body {
   height: 100%;
        width: 100%;
        background: #000000;
        font: 86% Arial, "Helvetica Neue", sans-serif;
        margin: 0;   
        padding: 0px;
        color: #CCCCCC;
    }
    #website_wrapper {
        min-height: 850px;
   min-width: 1080px;
        height: 100%;
        width: 100%;
    }
    #website {
        height: 100%;
        width: 100%;
        background-color: #000000;
        vertical-align: bottom;
    }
Run Code Online (Sandbox Code Playgroud)

有什么想法为什么 Safari(我猜是 WebKit)没有按照它的要求去做?提前致谢...

css safari macos

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

为什么Qt中的主窗口会消失?

创建一个简单的Qt4 Gui应用程序,围绕窗口构造并在if语句中显示命令并运行应用程序.
当我这样做时,窗口闪烁一微秒然后消失......为什么?
我在Windows 7 Pro上运行Qt Creator 1.2.1,基于Qt 4.5.2(32位).

#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    bool taut = true;
    if ( taut) {
        MainWindow w;
        w.show();
    }
    return a.exec();
}
Run Code Online (Sandbox Code Playgroud)

qt

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

从Python setuptools创建可启动的GUI脚本(没有控制台窗口!)

我目前为基于Python的GUI添加可执行文件的方式是:

setup(
      # ...
      entry_points = {"gui_scripts" : ['frontend = myfrontendmodule.launcher:main']},
      # ...
      )
Run Code Online (Sandbox Code Playgroud)

在Windows上,这将在Python的脚本文件夹(使用Python 2.6)中创建"frontend.exe"和"frontend-script.pyw".当我执行EXE文件时,会显示一个控制台窗口,但PYW文件无法正常显示.

所以我的问题是:如何在没有控制台窗口的情况下让EXE文件执行程序?该解决方案也适用于Linux(不建议使用py2exe;).

python distutils setuptools

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

将jQuery图表转换为PDF

我发现了两个我喜欢的jQuery图表插件 - flot和jqPlot.我正在考虑在我的网站的前端使用其中一个.

但是,我还需要能够允许用户以PDF格式导出数据.我理想地寻找纯Python解决方案,但可以推送到Java或PHP.生成的图表的质量是最重要的因素.

我考虑的选项是:

  • 在服务器上生成图表,并使用这些图表创建PDF.我已经看过matplotlib和其他几个python图表包,但图表看起来并不像flot或jqPlot那样精致.
  • 使用Rhino和Env.js在服务器上运行相同的jQuery代码,并以某种方式捕获生成的图表并将其插入到PDF中.这可能与Rhino有关吗?它有多难?我见过Rhino-canvas项目,但看起来已经过时了.

这样做的最佳方式是什么?如果我能让Rhino解决方案发挥作用,那就更好了,因为它保持了前端和生成的PDF之间的一致性.

python jquery charts

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

使用yield return的强类型方法接口

我真的很高兴能够在C#中做到这一点:

IEnumerable GetThePizzas()
{
    yield return new NewYorkStylePizza();
    yield return new SicilianPizza();
    yield return new GreekPizza();
    yield return new ChicagoStylePizza();
    yield return new HawaiianPizza();
}
Run Code Online (Sandbox Code Playgroud)

而在Java中,我会这样做:

Collection<Pizza> getThePizzas()
{
    ArrayList<Pizza> pizzas = new ArrayList<Pizza>();

    pizzas.add(new NewYorkStylePizza());
    pizzas.add(new SicilianPizza());
    pizzas.add(new GreekPizza());
    pizzas.add(new ChicagoStylePizza());
    pizzas.add(new HawaiianPizza());

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

请注意,Java代码告诉返回的类型(Pizza实例).C#代码没有.这让我很烦恼,尤其是在其他程序员无法访问源代码的情况下.有没有办法来解决这个问题?

更新:我的问题是我使用"System.Collections"而不是"System.Collections.Generic",因此我使用的是非通用版本的IEnumerable.

c# ienumerable

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

Java:泛型语法

这可以返回一个int列表:

public List<Integer> GetIListImpl() {
    return new ArrayList<Integer>();
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我想让调用者指定泛型类型呢?像这样的东西,虽然从语法上来说我不知道​​怎么做:

public List<T> GetIListImpl<T>() {
    return new ArrayList<T>();
}
Run Code Online (Sandbox Code Playgroud)

用法是:

    List<String> = GetIListImpl<String>();
Run Code Online (Sandbox Code Playgroud)

java generics

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

检查是否存在会话(Nginx)

我在PHP中有两个会话:

$_SESSION["session"]["key"] = md5 ($token . $userAgent . $ip);
$_SESSION["session"]["timeout"] = time ();
Run Code Online (Sandbox Code Playgroud)

只想检查与nginx的会话,尝试此代码但没有成功:

location / {
    if ($request_filename ~* "index.php") {
        break;
    }

    if ($http_cookie ~* "session") {
        break;
    }

    rewrite ^.+$ https://localhost/index.php last;
}
Run Code Online (Sandbox Code Playgroud)

有线索吗?

谢谢.

php session nginx

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

如何正确地乘以两个长多头?

我想乘以2 ^ 32基数给出的长数.我已经想到了一个很好的算法来做到这一点,但不幸的是我被卡住了.我坚持的情况是,我如何乘以两个长的整数并在2 ^ 32的基础上表示它.

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
typedef unsigned int uint32;
typedef unsigned long long uint64;
int main(int argc, char* argv[] )
{

  uint64 a = (uint64)ULONG_MAX;
  printf("%llu\n", a);
  uint64 b = (uint64)ULONG_MAX;  
  printf("%llu\n", b);  
  uint64 c = (uint64)(a*b);

  printf("%llu\n", c);  // prints 1. that would be to lower 32 bits of the results. the upper half is 0xFFFFFFFE

  printf("%llu\n", ULLONG_MAX);
  system("pause");
}
Run Code Online (Sandbox Code Playgroud)

为什么ULLONG_MAX与ULONG_MAX相同?根据http://en.wikipedia.org/wiki/Limits.h#Member_constants,它应该是18,446,744,073,709,551,615我

从我的评论中可以看出,我想要两个uint32中的multiplikation的结果.lowerhalf为0x1,上半部分为0xFFFFFFFE.我如何获得这些值?

(我在SO上发现了这个问题,但是对我的情况没有帮助,因为给出的答案与我的想法类似:乘以两个长的长C)

编辑: 我的系统是Windows XP 32位.我正在使用gcc 3.4.2(mingw-special)

我在运行代码时得到的输出: …

c multiplication unsigned-long-long-int

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

日期时间从格式创建

我想创建具有特定格式的日期,例如03-20-2010格式为mdY但日期功能不理解此日期并返回错误的日期

$date = date("Y-m-d", strtotime("03-20-2010"));
Run Code Online (Sandbox Code Playgroud)

上面的代码返回错误的日期,它背后的原因是什么以及如何避免错误的结果?我想要日期功能识别的格式很少是"Y/m/d","m/d/Y","F d,Y","M d,Y".

php datetime-format

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