我想让EditTextPreference不可编辑(例如,单击 "设置"页面中的项目时没有任何反应).我怎么做?
这是我的代码:
<PreferenceCategory android:title="My Account" >
<EditTextPreference
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:key="username_pref"
android:summary=" "
android:title="Username" >
</EditTextPreference>
</PreferenceCategory>
Run Code Online (Sandbox Code Playgroud)
我正在从相机中检索原始图像,图像的规格如下:
我将图像检索为字节数组,并具有2400(1/2*80*60)字节长的数组.下一步是将字节数组转换为位图.我已经用过了
BitmapFactory.decodeByteArray(bytes, 0, bytes.length)
Run Code Online (Sandbox Code Playgroud)
但是没有返回可显示的图像.我查看了这篇文章并将下面的代码复制到我的Android应用程序中,但是我得到了一个"不足以容纳像素的缓冲区"运行时错误.
byte [] Src; //Comes from somewhere...
byte [] Bits = new byte[Src.length*4]; //That's where the RGBA array goes.
int i;
for(i=0;i<Src.length;i++)
{
Bits[i*4] =
Bits[i*4+1] =
Bits[i*4+2] = ~Src[i]; //Invert the source bits
Bits[i*4+3] = -1;//0xff, that's the alpha.
}
//Now put these nice RGBA pixels into a Bitmap object
Bitmap bm = Bitmap.createBitmap(Width, Height, Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(ByteBuffer.wrap(Bits));
Run Code Online (Sandbox Code Playgroud)
在帖子的底部,原始海报与我目前有相同的错误.但是,他的问题已通过上面粘贴的代码修复.有没有人对如何将原始图像或RGBA数组转换为位图有任何建议?
非常感谢!
更新:
我按照Geobits的建议,这是我的新代码
byte[] seperatedBytes = new byte[jpegBytes.length * 8]; …Run Code Online (Sandbox Code Playgroud)