我想从bytearray创建一个位图.
我尝试了以下代码
Bitmap bmp;
bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
Run Code Online (Sandbox Code Playgroud)
和
ByteArrayInputStream bytes = new ByteArrayInputStream(data);
BitmapDrawable bmd = new BitmapDrawable(bytes);
bmp = bmd.getBitmap();
Run Code Online (Sandbox Code Playgroud)
但是,当我想用位图初始化Canvas对象时
Canvas canvas = new Canvas(bmp);
Run Code Online (Sandbox Code Playgroud)
它会导致错误
java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor
Run Code Online (Sandbox Code Playgroud)
然后如何从byteArray获取可变位图.
提前致谢.
我需要在Android中的活动的页面卷曲效果,如在iPhone中.
我检查了以下链接
http://code.google.com/p/android-page-curl/
https://github.com/harism/android_page_curl/
但两者仅对Bitmap(图像)有用,但我需要在startActivity()时使用卷曲效果,即当我要使用新的Activity时.
可能吗 ?如何 ?
我正在尝试使用给定列表中的MediaPlayer播放一首歌.我希望包括歌曲从开始到结束歌曲的持续时间.如何添加时间以及如何将该时间从0:00更新到该歌曲的结尾
我使用以下代码将HTTP控制器发送到HTTP服务器.
主要的是我还必须发送布尔值.
public void getServerData() throws JSONException, ClientProtocolException, IOException {
ArrayList<String> stringData = new ArrayList<String>();
DefaultHttpClient httpClient = new DefaultHttpClient();
ResponseHandler <String> resonseHandler = new BasicResponseHandler();
HttpPost postMethod = new HttpPost("http://consulting.for-the.biz/TicketMasterDev/TicketService.svc/SaveCustomer");
JSONObject json = new JSONObject();
json.put("AlertEmail",true);
json.put("APIKey","abc123456789");
json.put("Id",0);
json.put("Phone",number.getText().toString());
json.put("Name",name.getText().toString());
json.put("Email",email.getText().toString());
json.put("AlertPhone",false);
postMethod.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
String response = httpClient.execute(postMethod,resonseHandler);
Log.e("response :", response);
}
Run Code Online (Sandbox Code Playgroud)
但它在行中显示异常
String response = httpClient.execute(postMethod,resonseHandler);
Run Code Online (Sandbox Code Playgroud)
如
org.apache.http.client.HttpResponseException: Bad Request
Run Code Online (Sandbox Code Playgroud)
谁能帮我.
我需要显示android键盘支持的所有语言的列表.现在我正在使用Locale.getAvailableLocales();方法,但我得到语言和国家常数.
我只需要所有语言名称.可能吗?如何 ?.
我需要在我的应用程序中动态更改ListView的高度.
有没有办法做到这一点?
在我的项目中,我将解压缩SD卡中的文件.
但是文件是使用客户端证书压缩的,以确保它们无法在未授权查看文件的设备上解压缩.因此,使用gpg我们使用带有客户端证书的gpg-zip来创建zip文件 - 客户端证书安装在设备上,因此gpg-unzip应该只能解压缩,如果它有正确的证书."
所以,我必须使用GPG解压缩文件.
可能吗 ?如何 ?
提前致谢.
我正在使用 Android 中的 TranslateAnimation 做一个项目。因为我正在成功翻译图像,但我必须将 onClickListener 添加到图像中。这意味着我在翻译过程中单击了图像并获取了它们的值,但我正在对图像进行 onClick 操作。
我正在使用以下代码:
public class SampleGame extends Activity implements OnClickListener {
int x10, x20, y10, y20;
ImageView img;
Button animation;
Handler transHandler;
RelativeLayout layout;
Random rand;
int mSpeedX, mSpeedY;
int width, height;
Thread thread;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
layout = (RelativeLayout) findViewById(R.id.layout);
animation = (Button) findViewById(R.id.animation);
animation.setOnClickListener(this);
rand = new Random();
width = getWindow().getWindowManager().getDefaultDisplay().getWidth() - 20;
height = getWindow().getWindowManager().getDefaultDisplay().getHeight() - 70;
x10 = width - rand.nextInt(width);
y10 = height; …Run Code Online (Sandbox Code Playgroud) 我需要通过单击一个按钮来动态地向上和向下滚动ScrollView,我正在使用arrowScroll(int direction)方法.
但我不知道我必须为上下方向的方向参数赋予哪些值.
当我试图通过点击按钮退出应用程序时,我对钛非常新,它再次显示钛闪屏!
我使用以下代码
var win=Ti.UI.createWindow({
backgroundColor:'#ddd',
exitOnClose:true
});
var button=Ti.UI.createButton({
title:'back',
left:10,top:10
});
button.addEventListener('click',function(e){
win.close();
});
var text=Ti.UI.createLabel({
text:'Home page',
color:'#000',
font:{ fontSize:20}
});
win.add(button);
win.add(text);
win.open();
Run Code Online (Sandbox Code Playgroud)
如何通过按钮单击退出应用程序?
我想在WebView中打开以下链接
https://tickets.musiconelive.com/admin/SACValidateBarcode.asp
我使用以下代码来做到这一点
web=(WebView)findViewById(R.id.web);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("https://tickets.musiconelive.com/admin/SACValidateBarcode.asp");
Run Code Online (Sandbox Code Playgroud)
但它没有在WebView中打开,而是在浏览器中打开.
我该如何解决这个问题?