如果$('#id')与任何内容不匹配,返回什么?我认为这将是null或false或类似的东西所以我尝试检查如下:
var item = $('#item');
if (!item){
...
}
Run Code Online (Sandbox Code Playgroud)
但那没用.
我正在尝试将从相机中检索到的图像(大约5-8百万像素)缩小到一个较小的尺寸(最大为1024x768).我尝试了以下代码,但我一直得到一个OutOfMemoryError.
Bitmap image = BitmapFactory.decodeStream(this.image, null, opt);
int imgWidth = image.getWidth();
int imgHeight = image.getHeight();
// Constrain to given size but keep aspect ratio
float scaleFactor = Math.min(((float) width) / imgWidth, ((float) height) / imgHeight);
Matrix scale = new Matrix();
scale.postScale(scaleFactor, scaleFactor);
final Bitmap scaledImage = Bitmap.createBitmap(image, 0, 0, imgWidth, imgHeight, scale, false);
image.recycle();
Run Code Online (Sandbox Code Playgroud)
看起来OOM发生在createBitmap.是否有更高效的内存方式?也许某些东西不需要我将整个原件加载到内存中?
我有一个基本的自举面板,我希望它是4列宽.我尝试添加类,col-sm-4就像我任何其他div一样:
<div class="row">
<div class="panel panel-default col-sm-4">
<div class="panel-heading">Panel heading without title</div>
<div class="panel-body">
Panel content
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这得到了正确的宽度,但现在标题栏背景搞砸了:

如何使其符合该宽度但仍能正确呈现标题?
我需要一个代理Web开发调试.最好是独立的东西,所以我可以在IE和Firefox上使用它.我到目前为止使用的是CharlesProxy,但我希望找到一个免费的.有谁知道一个好的?
如何从拦截器中获取将在操作中调用的方法的名称?
我已经使用AccountAuthenticator创建了一个帐户类型,如SampleSyncAdapter教程中所做的那样.我现在正试图让帐户首选项工作.
我已将行添加android:accountPreferences="@xml/account_preferences"到my account-authenticator和account_preferences.xml中,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/alum_settings_title"/>
<CheckBoxPreference
android:key="sync_alum"
android:title="@string/sync_alum"
android:summaryOn="@string/sync_alum_check"
android:summaryOff="@string/sync_alum_nocheck"/>
<ListPreference
android:key="sync_alum_since"
android:title="@string/alum_years"
android:entries="@array/years"
android:entryValues="@array/years"
android:dependency="sync_alum"/>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
复选框首选项的工作方式与它应该完全相同,但ListPreference会使用以下消息使整个系统崩溃:
05-14 22:32:16.794: ERROR/AndroidRuntime(63): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
Run Code Online (Sandbox Code Playgroud)
我使用EditTextPreference和我创建的DialogPreference的自定义子类得到了相同的错误.
android ×2
css ×2
java ×2
bitmap ×1
generics ×1
interceptor ×1
javascript ×1
jquery ×1
proxy ×1
struts2 ×1