How to Repaint a View?

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

How to Repaint a View?

Postby sommeralex » Thu Feb 07, 2008 11:24 pm

Hello!

When i have an activity A with a GridView and start a subactivty B, and within this subactivity B i go back to activtiy A - then the screen (GridView) is empty. If i dragdrop on this empty screen, it seems that android "repaints" and the Grid appears again.

Is there any function i could call to "refresh" / "repaint" a view?

hence:

if i have an activity and setContentView - how can i "get" the view a-la "getContentView??!

-> i think the view-method "forceLayout" could help

alex
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Top

Postby Jesmiatka » Fri Feb 08, 2008 8:41 am

Hi,

I'm not sure since I didn't use this myself yet, but I think it is invalidate().

Yours sincerely,
Mike Jesmiatka
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby sommeralex » Fri Feb 08, 2008 9:59 am

thx! but HOW can i get my view which i set by setContentView on my Activity??

there is no "(View) getContentView"
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Postby Jesmiatka » Fri Feb 08, 2008 10:20 am

Hi,

don't know about that but I found some function that returns a View.

View.findFocus() will return the View that currently has the focus.
http://code.google.com/android/referenc ... findFocus()

View.getRootView() will return the Root view of the application.
http://code.google.com/android/referenc ... tRootView()

You might check out the View class for some functions.

Yours sincerely,
Mike Jesmiatka
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby sommeralex » Fri Feb 08, 2008 10:34 am

i know - but i meant from the activity class - i think its findViewById(int id) ;-)

thx!!
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Postby Jesmiatka » Fri Feb 08, 2008 10:35 am

Oops, my fault just read that you wanted to use your activity ;-)
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Top

Postby sommeralex » Fri Feb 08, 2008 11:48 am

nothing works...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. setContentView(R.layout.iconmenu);
  3.  
  4. iconTextGrid = (GridView) findViewById(R.id.myGrid);
  5.  
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


on resume, my GridView is still blank. I tried (on ActivtiyResult:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. findViewById(R.id.myGrid).postInvalidate();
  3.  
  4. findViewById(R.id.myGrid).invalidate();
  5.  
  6. iconTextGrid.forceLayout();
  7.  
  8.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


but nothing works.. :(
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Postby plusminus » Fri Feb 08, 2008 3:01 pm

Hello sommeralex,

what you experience is probably the known ListView Bug, which appears when you click the ListView then it gets scroll out of the screen :lol: . (The Bug is already reported and will be fixed within the next SDK-release).

If you use an Adapter the workaround (dirty) is to "re"set the Adapter.
We've already had a talk about the issue :arrow: :src: here.

Let me know if my assumption that your bug is the same is false. :)

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 sommeralex » Sun Feb 10, 2008 9:14 pm

sorry, i had a trip to hungary ;-) so i couldt work in the project and answer your mail:

i reset the adaper, but it didnt work. my work-arround now is that i just restart the menu as a whole..

thx
alex
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 24 guests