java - border not display in my images -


my gallery display images image select don't know how differentiate selected image , other images.. want set border line in image...now attach screen shots me....

my screenshot: alt text

i expect type of screen in emulator: alt text

package videothumb.videothumb;  import android.app.activity; import android.content.context; import android.content.intent; import android.database.cursor; import android.graphics.bitmap; import android.os.bundle; import android.provider.mediastore; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.baseadapter; import android.widget.gallery; import android.widget.imageview; import android.widget.listview; import android.widget.textview; import android.widget.toast; import android.widget.adapterview.onitemclicklistener; import android.net.uri; import android.view.window; import android.view.windowmanager; import android.graphics.color;  public class videothumb extends activity{  private final static uri media_external_content_uri =     mediastore.video.media.external_content_uri; private final static string _id = mediastore.video.media._id; private final static string media_data = mediastore.video.media.data; //flag 1 used images selection private gallery _gallery;  private cursor _cursor; private int _columnindex; private int[] _videosid; private uri _contenturi; private int video_column_index;  //private static final int menu_id_zoom = 0;   protected context _context; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     _context = getapplicationcontext();      setcontentview(r.layout.main);       //set gridview gallery     _gallery = (gallery) findviewbyid(r.id.videogrdvw);     //set default external/sdcard uri     _contenturi = media_external_content_uri;     //initialize videos uri      //showtoast(_contenturi.getpath());     initvideosid();     //set gallery adapter      setgalleryadapter();    } private void setgalleryadapter() {     _gallery.setadapter(new videogalleryadapter(_context));     _gallery.setonitemclicklistener(videogridlistener);     } private void initvideosid() {     try     {         //here set string array of thumbnail id column want         string [] proj={_id};         // create cursor pointing external thumbnail store         _cursor = managedquery(_contenturi,                 proj, // columns return                 null,       // clause; rows return (all rows)                 null,       // clause selection arguments (none)                 null); // order-by clause (ascending name)         int count= _cursor.getcount();         system.out.println("total"+_cursor.getcount());         // column index of thumbnail id         _columnindex = _cursor.getcolumnindex(_id);         //initialize          _videosid = new int[count];         //move position first element         _cursor.movetofirst();                     for(int i=0;i<count;i++)         {                         int id = _cursor.getint(_columnindex);             //              _videosid[i]= id;             //             _cursor.movetonext();             //         }     }catch(exception ex)     {         showtoast(ex.getmessage().tostring());                 }      }    protected void showtoast(string msg)    {      toast.maketext(_context, msg, toast.length_long).show();    }    private onitemclicklistener videogridlistener = new onitemclicklistener() {      public void onitemclick(adapterview parent, view v, int position,     long id) {         // want data location of file         string [] proj={media_data};         // request our cursor again         _cursor = managedquery(_contenturi,                 proj, // columns return                 null,       // clause; rows return (all rows)                 null,       // clause selection arguments (none)                 null);           //system.gc();          // video_column_index =                                _cursor.getcolumnindexorthrow(mediastore.video.media.data);           _columnindex = _cursor.getcolumnindex(media_data);             // lets move selected item in cursor             _cursor.movetoposition(position);            string filename = _cursor.getstring(_columnindex);           intent intent = new intent(videothumb.this, viewvideo.class);           intent.putextra("videofilename", filename);           startactivity(intent);           showtoast(filename);          // toast.maketext(videothumb.this, "" + position, toast.length_short).show();           }        };     private class videogalleryadapter extends baseadapter     {     public videogalleryadapter(context c)      {         _context = c;      }     public int getcount()      {         return _videosid.length;     }     public object getitem(int position)      {         return position;     }     public long getitemid(int position)      {         return position;     }     public view getview(int position, view convertview, viewgroup parent)      {         imageview imgvw= new imageview(_context);         try         {             if(convertview!=null)             {                 imgvw= (imageview) convertview;             }             imgvw.setimagebitmap(getimage(_videosid[position]));             imgvw.setadjustviewbounds(true);             //imgvw.draw(canvas);             //imgvw.setbackgroundcolor(color.black);             imgvw.setlayoutparams(new gallery.layoutparams(150, 100));             imgvw.setpadding(5,5,5,5);         }         catch(exception ex)         {             system.out.println("startactivity:getview()-135: ex " + ex.getclass() +",            "+ ex.getmessage());         }         return imgvw;     }      // create thumbnail on fly     private bitmap getimage(int id) {     bitmap thumb = mediastore.video.thumbnails.getthumbnail(getcontentresolver(),id,      mediastore.video.thumbnails.micro_kind, null);       system.out.println("ff"+mediastore.video.thumbnails.getthumbnail      (getcontentresolver(),      id, mediastore.video.thumbnails.micro_kind, null));         return thumb;     }       }            } 

alt text

i set background color....

you can set background color of imageview same border color. , set padding of imageview size of border. work want.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -