[Solved] Problem with Focus

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

[Solved] Problem with Focus

Postby Oleg » Fri Dec 21, 2007 11:46 am

Hi all! I have problem!I have element with focus, and when i load other element with focus in my view I can not lose focus from new element! How can I move from one element to other one?
Oleg
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Wed Nov 28, 2007 1:49 pm
Location: Ukraine

Top

Postby snowtiger » Fri Dec 21, 2007 12:24 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. yourViewThatWantsFocus.requestFocus();
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Note that this calls onFocusChanged() of your view, so you can do some stuff with a listener:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. yourViewThatWantsFocus.setOnFocusChangeListener(new View.OnFocusChangeListener() {
  2.  
  3.                 public void onFocusChanged(View button, boolean currentFocus) {
  4.  
  5.                         doWhatYouWantWhenThisViewHasFocusGainedOrLost();
  6.  
  7.                 }
  8.  
  9. });
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
snowtiger
Developer
Developer
 
Posts: 34
Joined: Fri Dec 21, 2007 10:44 am

Postby plusminus » Fri Dec 21, 2007 4:55 pm

Hello Oleg,

you can already do ".requestFocus" within your xml-layout, like this:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.         <Button ...>
  2.             <requestFocus/>
  3.         </Button>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


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 Oleg » Fri Dec 21, 2007 5:08 pm

Thanks
Oleg
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Wed Nov 28, 2007 1:49 pm
Location: Ukraine

Top

Return to Other Coding-Problems

Who is online

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