some problem in code,anyone solved it

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

some problem in code,anyone solved it

Postby palak1302 » Thu Jan 31, 2008 5:58 pm

hi everyone,
i have some problem in my code...i try to show gallery layout in my code...
in my code

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle icicle) {
  2.  
  3.   setContentView(R.layout.main);
  4.  
  5.  addContentView(myview,new new LinearLayout.LayoutParams(
  6.  
  7.                     LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  8.  
  9. }
  10.  
  11.  
  12.  
  13. class myview extends View
  14.  
  15.  
  16.  
  17.  protected void onDraw(Canvas canvas) {
  18.  
  19. {
  20.  
  21. mCanvas.drawRoundRect.................
  22.  
  23. mCanvas.drawRoundRect................
  24.  
  25.   Gallery gallery = (Gallery) ((Activity)ctx).findViewById(R.id.gallery);
  26.  
  27.   gallery.setAdapter(new myAdapter(ctx));
  28.  
  29.  
  30.  
  31. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4



it's called myAdapter class but did not display any image.what is problem behind that??how to use Gallery Layout in onDraw method??
palak1302
Junior Developer
Junior Developer
 
Posts: 23
Joined: Thu Jan 31, 2008 5:17 pm

Top

Postby plusminus » Thu Jan 31, 2008 8:26 pm

Hello palak1302,

remember that onDraw(...) gets called every single time your View gets invalidated!
Are you sure you have to setAdapter every time :?:

Regards,
plusminus
Last edited by plusminus on Fri Feb 01, 2008 11:32 am, edited 1 time in total.
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 palak1302 » Fri Feb 01, 2008 8:50 am

yes, im sure ..i have setAdapter when i called OnDraw(......).but this way it's not working
palak1302
Junior Developer
Junior Developer
 
Posts: 23
Joined: Thu Jan 31, 2008 5:17 pm

Postby plusminus » Fri Feb 01, 2008 7:53 pm

Hello palak1302,

you've had a look at the Gallery-Tutorial :?:
Code there is working well.

Second thing there is you are drawing to "mcanvas" but the canvas visible to the user is the canvas that is coming in as the parameter "canvas".

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

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests