android - Display Item horizontally? -
android - Display Item horizontally? -
all want display image info rss-feed. rss feed code working fine image loading feed, unable display image in horizontal way? tried gallery unable set image that? there way accomplish same?
i refer link http://www.dev-smart.com/archives/34 implement horizontal listview in unable implement onclicklistener list. help please. give thanks you.
the code tried gallery..
public class imageadapter extends baseadapter {
int imagebackground; private list<rssiteam> objects = null; private context context; public imageadapter(context c) { context = c; typedarray ta = obtainstyledattributes(r.styleable.gallery1); imagebackground = ta.getresourceid(r.styleable.gallery1_android_galleryitembackground, 1); ta.recycle(); } public imageadapter(context context, int textviewresourceid, list<rssiteam> objects) { super(); this.context = context; this.objects = objects; } @override public int getcount() { homecoming this.objects.size(); //return pics.length; } @override public object getitem(int position) { homecoming this.objects.get(position); //return position; } @override public long getitemid(int position) { homecoming position; } @override public view getview(int position, view convertview, viewgroup parent) { rssiteam info = (rssiteam) getitem(position); string imageurl = data.imageurl; seek { url feedimage = new url(imageurl); httpurlconnection conn= (httpurlconnection)feedimage.openconnection(); inputstream = conn.getinputstream(); bitmap img = bitmapfactory.decodestream(is); } grab (malformedurlexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } imageview iv = new imageview(context); iv.setimageresource(img[position]); //here unable set image in particular position because require int type array iv.setscaletype(imageview.scaletype.fit_xy); iv.setlayoutparams(new gallery.layoutparams(90,70)); iv.setbackgroundresource(imagebackground); homecoming iv; }
}
you can utilize galleryholder.xml. xml contains imageview , inflate adapter , homecoming view , adapter filled view in gallery.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="100dp" android:layout_height="fill_parent" android:background="@drawable/my_border" android:orientation="vertical" android:padding="5dp" > <imageview android:id="@+id/storyimage" android:layout_width="fill_parent" android:layout_height="70dp" android:scaletype="fitxy" /> </linearlayout> , utilize image adapter fill gallery galleryid.setadapter(new imageadapter()); image adapter code @override public view getview(int position, view convertview, viewgroup parent) { layoutinflater layoutinflater=(layoutinflater) context.getsystemservice(context.layout_inflater_service); view view=(view)layoutinflater.inflate(r.layout.galleryholder,parent,false); imageview iv; if(convertview==null){ convertview=view; iv=(imageview)view.findviewbyid(r.id.storyimage); } rssiteam info = (rssiteam) getitem(position); string imageurl = data.imageurl; seek { url feedimage = new url(imageurl); httpurlconnection conn= (httpurlconnection)feedimage.openconnection(); inputstream = conn.getinputstream(); bitmap img = bitmapfactory.decodestream(is); } grab (malformedurlexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } iv.setimageresource(img[position]); //here unable set image in particular position because require int type array iv.setscaletype(imageview.scaletype.fit_xy); iv.setlayoutparams(new gallery.layoutparams(90,70)); iv.setbackgroundresource(imagebackground); homecoming convertview; }
android listview android-gallery horizontallist
Comments
Post a Comment