0
嗨我是新來android和im試圖放大圖像,如果點擊..問題是我想放大的圖像是從數據庫中... 這裏是我的XML代碼..如果點擊放大從遠程服務器檢索到的圖像 - Android
`<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_weight="50"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/labresultimage"
android:layout_width="460dp"
android:layout_height="320dp"
android:src="@drawable/laboratory" />
</LinearLayout>`
這是我的Java代碼..
`package info.androidhive.slidingmenu;
import java.io.InputStream;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;
public class LaboratoryResultInformation extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.laboratoryresultinformation);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
//display image using passed url
final String MY_URL_STRING = extras.getString("IMAGEURL_EXTRA");
new DownloadImageTask((ImageView) findViewById(R.id.labresultimage))
.execute(MY_URL_STRING);
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}
}`
我GOOGLE了,但唯一的代碼,我發現如果圖像本身已經位於/保存的作品drawables ..