小编Hos*_*kli的帖子

来自相机或画廊的图片?

我有一个意图选择器,允许我从画廊或相机中选择图像,如下所示:

    Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT,null);
    galleryIntent.setType("image/*");
    galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);

    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 


    Intent chooser = new Intent(Intent.ACTION_CHOOSER);
    chooser.putExtra(Intent.EXTRA_INTENT, galleryIntent);      
    chooser.putExtra(Intent.EXTRA_TITLE, "title");

    Intent[] intentArray =  {cameraIntent}; 
    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
    startActivityForResult(chooser,REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)

我希望我的onActivityResult方法是这样的:

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if(Condition == picture_coming_from_gallery)
    {
     //my code here
    }
    else if(condition == picture_coming_from_camera)
    {
     //another code here
    }
}
Run Code Online (Sandbox Code Playgroud)

是什么条件让我知道我的图像来自哪个来源?

更新:

现在它正在运行,这是解决方案:

    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK)
    { …
Run Code Online (Sandbox Code Playgroud)

android gallery android-intent android-camera-intent

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

将整数表 - int [] - 插入SQLite数据库,

是否可以将整数表插入int[] numbers到SQLite表中?

如何创建我放这个表的列?

这行代码:

values.put(MySqlHelper.COLUMN_CHILDS, numbers);
Run Code Online (Sandbox Code Playgroud)

给我一个错误,如:

Change type of `numbers` to `String`
Run Code Online (Sandbox Code Playgroud)

java arrays sqlite insert

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

外键与辅助键

我曾经认为外键和二键是一回事.

在Google搜索之后,结果更加令人困惑,有些人认为它们是相同的,其他人则认为辅助键是一个不必是唯一的索引,并且允许比使用主键更快地访问数据.

有人可以解释这个区别吗?
或者它确实是混合术语的情况?
每个数据库类型可能有所不同吗?

sql

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

阅读HttpPost响应

我正在使用此代码将请求发布到http服务器:

HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost( "http://192.168.0.1/test.php" );
HttpResponse response = null;
try {
    List< NameValuePair > nameValuePairs = new ArrayList< NameValuePair >( 1 );
    nameValuePairs.add( new BasicNameValuePair( "num", "2" ) );
    post.setEntity( new UrlEncodedFormEntity( nameValuePairs ) );
    response = client.execute( post );
}
catch( ClientProtocolException e ) {
    ...
}
catch( IOException e ) {
    ...
}
Run Code Online (Sandbox Code Playgroud)

回应只不过是简单的String.我该怎么读这个回复String?似乎HttpResponse没有直接执行此操作的方法.

java android http

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

浮动后离开时遇到故障

我试图水平放置两个div,但是第二个div的内容超过了第一个div的高度我得到了不好的结果:

这是我的Html代码:

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="mystyle.css"></head>
<body>

<div class="container">
<div class="yellow">sometext</div>
<div class="green">more text here more text here more text here more text here more     text here more text here more text here more text here more text here more text     here </div>
<div class="spacer"></div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)

这是我的Css:

.yellow {
background-color: yellow;
margin: 2px;
float: left;
width: 100px;
text-align: center;
}

.green{
background-color: #00ff00;
      }

.container {
width: 30%;
}

.spacer {
 clear: both; …
Run Code Online (Sandbox Code Playgroud)

html css-float

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

新的JQuery.Deferred(); 不是构造函数

我昨天在这里问了一个问题,我得到了一个很好的答案,这行代码var def = new jQuery.Deferred(); 代码在jsfiddle.net正常工作,但是我的firebug说TypeError: jQuery.Deferred is not a constructor,并且用这段代码var def = jQuery.Deferred();说它TypeError: jQuery.Deferred is not a function

jquery

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