हाय दोस्तों, अच्छी तरह से मैं आईडी नंबर के अनुसार सर्वर से छवियों को लोड करने की कोशिश कर रहा हूं, तो यह webservice से इसे पुनः प्राप्त करने का सबसे अच्छा तरीका होगा क्या कोई मुझे मार्गदर्शन कर सकता है? ?वेब सेवा से एंड्रॉइड एप्लिकेशन पर छवि कैसे प्राप्त करें
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 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>
- इस कोडिंग के साथ की कोशिश की, लेकिन मैं केवल छोटे आकार छवियों के साथ काम कर सकता था जब मैं बड़ा आकार छवियों यह काम करता है नहीं करता है के लिए जाना है, यह एक ही रहता है, मैं नहीं कर सकते किसी भी त्रुटि को एक ही स्क्रीन दिखाते हुए
अपने प्रश्न का वर्णन करें। क्या आप एक्सएमएल पार्स कर रहे हैं ?? –
एंड्रॉइड में यूनिवर्सल इमेज लोडर को खोजने का प्रयास करें –
कृष्णा सुथर एक्टुल्ली मैंने दोनों प्रकार के यूआरएल के साथ कोशिश की और बेस 64 कनवर्शन स्ट्रिंग में भी जब मैं उपरोक्त कोड के साथ जांच करता हूं तो मैं छोटे आकार की छवियों को लोड करने में सक्षम हो सकता हूं, – user1389233