i am storing the imagesurl in an arrayadapter. i want to display all
the images that i get from the server in a gallery.
i am pasting my code here can anyone tell me what i am doing wrong??

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

ImageView imView;
public NodeList n_thumbnail;
public NodeList n_gphoto_id;
public NodeList n_album_id;
public ArrayList<String> imgurl = new ArrayList<String>();
public ArrayList<String> photoid = new ArrayList<String>();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
r= new Random();
((Gallery) findViewById(R.id.gallery))
.setAdapter(new ImageAdapter(this));
try {
String s=makeHttpRequest("userid", "password");
System.out.println(s);
getPhotos(s,"5435451056290802193");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

private void getPhotos(String auth,String albumid)throws IOException
{
try
{

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
System.out.println("Inside fn************");
String s="http://picasaweb.google.com/data/feed/api/user/userid/
albumid/"+albumid+"?
fields=entry(media:group(media:thumbna...@width='72']),gphoto:id,gphoto:albumid)";
URL url = new URL(s);
HttpURLConnection httpConnection = (HttpURLConnection)
url.openConnection();
httpConnection.setRequestProperty(AUTH_HEADER_KEY,
String.format(AUTH_HEADER_VALUE_TEMPLATE, auth));
Document doc = db.parse(httpConnection.getInputStream());
n_thumbnail=doc.getElementsByTagName("media:thumbnail");
n_gphoto_id=doc.getElementsByTagName("gphoto:id");
n_album_id=doc.getElementsByTagName("gphoto:albumid");
int i=0;
while(i<n_gphoto_id.getLength())
{
Element element = (Element)n_thumbnail.item(i);
imgurl.add(element.getAttribute("url"));
//imgurl.addAll(collection)
System.out.println(element.getAttribute("url"));
photoid.add(n_gphoto_id.item(i).getFirstChild().getNodeValue());
System.out.println(n_gphoto_id.item(i).getFirstChild().getNodeValue());
System.out.println(n_album_id.item(i).getFirstChild().getNodeValue());
i++;

}


BufferedReader reader = new BufferedReader(new
InputStreamReader(httpConnection.getInputStream()));
String line;
System.out.println("Inside fn************");
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();





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

}
}

public class ImageAdapter extends BaseAdapter {
/** The parent context */
private Context myContext;
//int i=0;


/** Simple Constructor saving the 'parent' context. */
public ImageAdapter(Context c) { this.myContext = c; }

/** Returns the amount of images we have defined. */
public int getCount() { return imgurl.size();}

/* Use the array-Positions as unique IDs */
public Object getItem(int position) { return position; }
public long getItemId(int position) { return position; }

/** Returns a new ImageView to
* be displayed, depending on
* the position passed. */
public View getView(int position, View convertView, ViewGroup parent)
{
ImageView i = new ImageView(this.myContext);

try {
System.out.println("Inside image adapter" );
/* Open a new URL and get the InputStream to load data from it. */
for(int j =0;j<imgurl.size();j++){

URL url2= (URL) new URL(imgurl.get(0).toString());
System.out.println(url2.toString());
//HttpURLConnection httpConnection1 =
(HttpURLConnection)url2.openConnection();
URLConnection conn = url2.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis =new BufferedInputStream(is);
Bitmap b = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
imView.setImageBitmap(b);
}
} catch (IOException e) {
//i.setImageResource(R.drawable.error);
Log.e("DEBUGTAG", "Remtoe Image Exception", e);
}

/* Image should be scaled as width/height are set. */
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
/* Set the Width/Height of the ImageView. */
i.setLayoutParams(new Gallery.LayoutParams(150, 150));
return i;
}
}


i can see the image url's in the logcat portion however i cannot see
anything on the emulator screen.that is the gallery code isn't
working.
can anyone please help me out here.its urgent as i need to submit my
project at the earliest
thanks in advance

-- 
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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to