Problem with getView ...

Put your problem here if it does not fit any of the other categories.

Postby soniya » Mon Jan 21, 2008 2:26 pm

i m used code

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  public View getView(int position, View convertView, ViewGroup parent) {
  2.  
  3.            LinearLayout ll = new LinearLayout(this.mContext);
  4.  
  5.             ImageView i = new ImageView(this.myContext);
  6.  
  7.             i.setImageResource(this.myImageIds[position]);
  8.  
  9.             /* Image should be scaled as width/height are set. */
  10.  
  11.             i.setScaleType(ImageView.ScaleType.FIT_XY);
  12.  
  13.             /* Set the Width/Height of the ImageView. */
  14.  
  15.             i.setLayoutParams(new Gallery.LayoutParams(150, 150));
  16.  
  17.             TextView tv = new TextView(this.mContext);
  18.  
  19.               tv.setText(mContext.getString(myImageIds[position]));
  20.  
  21.          ll.addView(tv,new    LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  22.  
  23.             return i;
  24.  
  25.         }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4



but it's cannot show any text.......where is problem plz tel me............ :roll:
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Top

Postby plusminus » Mon Jan 21, 2008 6:50 pm

Hello soniya,

probably because your are adding the TextView to LinearLayout and return only the ImageView.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby soniya » Tue Jan 22, 2008 10:05 am

thank you for reply.....then how to set text view in bottom for image in u'r A android.widget.Gallery - Example
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby soniya » Wed Jan 23, 2008 2:02 pm

hi all,
Anyone tel me In A android.widget.Gallery - Example..how to add name of image on screen...and change name when we scroll image... :?:
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby raquibulbari » Wed Jan 23, 2008 3:03 pm

return ll; you r only returning i

that will solve your problem :D
Shimugool
User avatar
raquibulbari
Developer
Developer
 
Posts: 25
Joined: Sun Dec 16, 2007 6:31 am
Location: dhaka,bangladesh

Postby soniya » Thu Jan 24, 2008 9:50 am

thanks you............but when i used in getview method

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.   ll.addView(i);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


then it's show "invalid LayoutParams supplied" i want image and image's name both are display..... :roll:
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Top

Postby plusminus » Thu Jan 24, 2008 10:38 am

Hello soniya,

I didn't have a look at the Documentation, but this is very probably your error:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. i.setLayoutParams(new Gallery.LayoutParams(150, 150));
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

Search for the appropriate LayoutParams to pass.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby soniya » Thu Jan 24, 2008 2:21 pm

in LinearLayout, will we set Gallery LayoutParams???

im saying that
will we used
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  ll.addView(i,new Gallery.LayoutParams(150, 150));
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby plusminus » Thu Jan 24, 2008 5:24 pm

Hello soniya,

please post your current code, because it is really hard to follow what you are saying.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby burakkilic » Fri Nov 13, 2009 5:34 pm

plusminus do you know a good idea for getting remote images into the gallery? My code is some laggy, because it receives the images everytime it calls getView. Any idea?
burakkilic
Developer
Developer
 
Posts: 37
Joined: Thu Oct 01, 2009 10:24 am

Re:

Postby MMarko » Sat Oct 09, 2010 10:50 am

soniya wrote:i m used code

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  public View getView(int position, View convertView, ViewGroup parent) {
  2.            LinearLayout ll = new LinearLayout(this.mContext);
  3.             ImageView i = new ImageView(this.myContext);
  4.             i.setImageResource(this.myImageIds[position]);
  5.             /* Image should be scaled as width/height are set. */
  6.             i.setScaleType(ImageView.ScaleType.FIT_XY);
  7.             /* Set the Width/Height of the ImageView. */
  8.             i.setLayoutParams(new Gallery.LayoutParams(150, 150));
  9.             TextView tv = new TextView(this.mContext);
  10.               tv.setText(mContext.getString(myImageIds[position]));
  11.          ll.addView(tv,new    LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  12.             return i;
  13.         }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4



but it's cannot show any text.......where is problem plz tel me............ :roll:


I have the same problem, how did you solve?
MMarko
Freshman
Freshman
 
Posts: 7
Joined: Sun May 09, 2010 3:11 pm
Location: Italy

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests