i am developing an app which shows thumbnail of images using grid view i created image adapter class to get the thumbnail images , but it is not working plse help me(force close)
here is my code package com.playswf; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; public class playswf extends Activity { String[] imageURLs = new String[100]; Bitmap bitmap; ArrayList<String>list=new ArrayList<String>(); public JSONObject json; int count; // String[] mylist =new String[100]; //private ImageAdapter imageAdapter; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //getimageurl(); GridView sdcardImages = (GridView) findViewById(R.id.gridview); list.add("http://works.sodprojects.com/mobile/$userfiles/thumb_82_431_39.jpg "); list.add("http://works.sodprojects.com/mobile/$userfiles/thumb_82_431_39.jpg "); list.add("http://works.sodprojects.com/mobile/$userfiles/thumb_82_431_39.jpg "); sdcardImages.setAdapter(new ImageAdapter(this)); // Toast.makeText(getBaseContext(), // " selected"+ list.toString() , // Toast.LENGTH_SHORT).show(); } private class ImageAdapter extends BaseAdapter { private final Context context; public ImageAdapter(Context localContext) { context = localContext; } public int getCount() { return list.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView picturesView; if (convertView == null) { picturesView = new ImageView(context); for(int i=0;i<list.size();i++) { Bitmap mBitmap = BitmapFactory.decodeFile(list.get(i)); picturesView.setImageBitmap(mBitmap); } picturesView.setScaleType(ImageView.ScaleType.FIT_CENTER); picturesView.setPadding(8, 8, 8, 8); picturesView.setLayoutParams(new GridView.LayoutParams(100, 100)); } else { picturesView = (ImageView)convertView; } return picturesView; } } private ArrayList<String> getimageurl() { json =JsonImplementation.getJSONfromURL(" http://works.sodprojects.com/mobile/mobile/ViewPhotos/?id=82"); // Toast.makeText(getBaseContext(), // " selected"+ json .toString(), // Toast.LENGTH_SHORT).show(); try{ JSONArray data = json.getJSONArray("result"); count =data.length(); for(int i=0;i<data.length();i++){ JSONObject e = data.getJSONObject(i); //getting the value of message_id and conversation_id //MainActivity.MESSAGE_ID=e.getString("username"); list.add("http://works.sodprojects.com/mobile/"+e.getString("Photo")); //list[i]="http://works.sodprojects.com/mobile/"+e.getString("Photo"); } /// Toast.makeText(getBaseContext(), // " selected"+ mylist[0], // Toast.LENGTH_SHORT).show(); } catch(JSONException e) { Log.e("log_tag", "Error parsing data "+e.toString()); } return list; // TODO Auto-generated method stub } public static Bitmap downloadFile(String fileUrl){ Bitmap bmImg = null; URL myFileUrl =null; try { myFileUrl= new URL(fileUrl); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bmImg = BitmapFactory.decodeStream(is); // imView.setImageBitmap(bmImg); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bmImg; } } xml file <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="auto_fit" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:columnWidth="90dp" android:stretchMode="columnWidth" android:gravity="center" /> urgent............ thnks -- -- ωιтн яєgαя∂ѕ Ratheesh * *........... -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en