как получить изображение из веб-службы в приложение для Android

Привет, ребята, я пытаюсь загрузить изображения с сервера в соответствии с идентификационным номером, так что лучший способ получить их из веб-сервиса, может ли кто-нибудь помочь мне??

package com.crispsys;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class imageviewer extends Activity {
    /** Called when the activity is first created. */

    Bitmap image; 
    private TextView ordernumber;
     ImageView imageView;
     private Button butt;
     String Str="image",ordno;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.imageviewerr);

         this.butt = (Button) this.findViewById(R.id.getbutt);
          this.imageView =(ImageView) findViewById(R.id.blodig);
          this.ordernumber=(TextView)this.findViewById(R.id.ordernotext);

          final Bundle getdata = getIntent().getExtras();

          if (getdata != null)    
          {
              ordno=getdata.getString("orono");
              ordernumber.setText(ordno);
          }


        this.butt.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub


                Toast.makeText(getApplicationContext(),"loading" , Toast.LENGTH_LONG).show();

                      URL url = null;


                      try 
                      {

                          url = new URL("http://www.cyberstudents.in/aaa/car.jpg");

                      }
                      catch (MalformedURLException e) 
                      {
                          e.printStackTrace();
                      }
                      try {
                          image = BitmapFactory.decodeStream(url.openStream());

                      } 
                      catch (IOException e) 
                      {
                          e.printStackTrace();
                      }

                imageView.setImageBitmap(image);
            }
        });

    }
}

XML-файл:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@drawable/cr_isp"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:gravity="center"
        android:paddingTop="20dp"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/ordernotext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#8B8682"
            android:text="" />


    </TableRow> 

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:gravity="center"
        android:paddingTop="20dp"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/getbutt"
            android:layout_width="210dp"
            android:layout_height="40dp"
            android:background="@drawable/bcbut"
            android:textColor="#8B8682"
            android:text="Get Block Dig" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="match_parent"
        android:gravity="center"
        android:paddingTop="20dp"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/blodig"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher" />

    </TableRow>

</LinearLayout>
  • Пробовал с этим кодированием, но я мог работать только с изображениями небольшого размера, когда я перешел к изображениям большого размера, он не работает, он остается таким же, я не могу найти никакой ошибки, он показывает тот же экран
5
задан user1389233 15 May 2012 в 10:15
поделиться