Monday, 18 June 2012

Load Image From URL in ListView in android part 2

2) Now Create ImageData Class for store and fatch image url from webpage:-


public class ImageData {


public static ArrayList<String> icon=new ArrayList<String>();
public static ArrayList<String> fullimage=new ArrayList<String>();
public static ArrayList<String> name=new ArrayList<String>();

public static  void loaddata()
{
try {
Document doc = Jsoup.connect("http://www.fundumobi.com/RakhiSpecial/mypage.html").get();
System.out.println("jj"+doc.text());
StringTokenizer st1 = new StringTokenizer(doc.text(), "#");
int count=0;
while(st1.hasMoreTokens()){
String str=st1.nextToken();
StringTokenizer st = new StringTokenizer(str, "|");
int cont=0;
while(st.hasMoreTokens())
{
String s=st.nextToken();
System.out.println("jj"+s);
if(cont==0)
{
icon.add(s);
}
else if (cont==1)
{
fullimage.add(s);
}
else if (cont==2)
{
name.add(s);
}
cont++;
if(cont>2)
cont=0;
}


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


}


3) Also create



public class Utils {
    public static void CopyStream(InputStream is, OutputStream os)
    {
        int buffer_size;
try {
buffer_size = is.available();

        try
        {
            byte[] bytes=new byte[buffer_size];
            for(;;)
            {
              int count=is.read(bytes, 0, buffer_size);
              if(count==-1)
                  break;
              os.write(bytes, 0, count);
            }
        }
        catch(Exception ex){}
        
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//1024;
    }
}


1 comment:

  1. Change your website design first , idiot !!!!

    ReplyDelete