Borders for gridview items in android -


I retrieved the image DB + and a Gridwukaiki. Displayed in gridview right.Sure of each item + a text.It thing I know I just want to how to determine the extent of each gridview item separately android.How consists of an image can I do?

My code is. .

  public class homepage activity increases (personal Aerelist & lt; Singlelement Sex & gt; AllElementDetails = new ArrayList & lt; SingleElementDetails & gt; (); DBAdapter db = new DBAdapter (this) ; string category, description, string data, string data 1; Gridwu Gridwuwu button menu; public Crate zero (bundle saved Instansstet) {Suprknkret (saved Instensstet); SetContentView (Rklayoutkhomepage); menu = (Button) findViewById (R.id.menus); menu.setOnClickListener (New OnClickListener () {abstract Wajnik View void onClick (v) {gridview = (GridView) findViewById (R.id.gridview); TypedArray a = obtainStyledAttributes (R.styleable.Gallery); integer mGalleryItemBackground = a.getResourceId (R.styleable.Gallery1_android_galleryItemBackground, 0); a.recycle (); allElementDetails.clear (); db.open (); long ID; //id=db1.insertTitle1(category, details, r_photo); cursor = db. getAllTitles1 (); while (cursor.moveToNext ()) {SingleElementDetails Single = New SingleElementDetails (); Single.setDishName (cursor.getString (1)); Single.setCateogry (cursor.getString (2)); Single.setDescription (cursor .getString (3)); Single.setImage (cursor.getBlob (4)); AllElementDetails.add (single);} db.close (); CustomListAdapter Adapter = New CustomListAdapter (HomePage.this, allElementDetails); Gridview.setAdapter (adapter); Gridview.setBackgroundResource (mGalleryItemBackground);}}); }}   

I used customList adapter to store data retrieved from DB. My customist adapter code is ...

  Public category custom list adapter bidders {Private Arrayist & lt; Single Element Details & gt; AllElementDetails; Private layoutInflator aminflator; Public CastelList Adapter (Reference Reference, Arrayist & lt; SingleAlement Details & gt; Results) {allElementDetails = Results; MInflater = layoutInflator. From (context); } Public int getCount () return {allElementDetails.size ()}} public object getItem (integer position) {allElementDetails.get (status); } Public ITMID in the long run (status of return) {Return Status; } View public viewView (int position, seeviewview, ViewGroup parent) {convertView = mInflater.inflate (R.layout.listview1, null); ImageView imageview = (ImageView) Convert View.findViewById (R.id.image); TextView textview1 = (TextView) ConvertviewFindvibid (R.id.dishname_entry); TextView textview2 = (TextView) Convert View.findViewById (R.id.category_entry); TextView textview3 = (TextView) Convert View.findViewById (R.id.description_entry); Textview1.setText (allElementDetails.get (status) .getDishName ()); Textview2.setText (allElementDetails.get (status) .getCategory ()); If (allElementDetails.get (status) .getDescription () Length ()> 8) textview3.setText (.allElementDetails.get) .getDescription () Substring (0,8) + "..."); Else textview3.setText (All ElementDetails.get (status) .getDescription ()); Byte [] byteimage = allElementDetails.get (status) .getImage (); Bytereinputstream imagestream = new bytereinputstream (biometimate); Bitmapfile Option Option = New Bitmap Feature. Option (); Op.inSampleSize = 12; Bitmap theImage = BitmapFactory.decodeStream (imagestream, blank, op); Imageview.setImageBitmap (theImage); Return Convertview; Perhaps an easy way but possibly creating an XML as a drawable in drawable.  

File Location:

   

Res / drawable / filename.xml

The file name is used as the resource ID.

  & lt ;? Xml version = "1.0" encoding = "utf-8" & gt; & Lt; Layer-list xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Items & gt; & Lt; Bitmap android: src = "@drawable / rectangle" /> & Lt; / Item & gt; & Lt; Items & gt; & Lt; Bitmap android: src = "@drawable / griddream" /> & Lt; / Item & gt; & Lt; Items & gt; & Lt; Nine patch & gt; Other etc ... & lt; / Item & gt; & Lt; Items & gt; Other drawables etc. & Lt; / Item & gt; & Lt; / Layer-list & gt;   

It can be used as a draw or bitmap like:

  bitmap bitmap = bitmapfiredirectores resource (getApplicationContext.getResources (), R.drawable.filename);   

some documents

Comments