How to make Views in a GridView hightlight-able by keyAction

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

How to make Views in a GridView hightlight-able by keyAction

Postby sommeralex » Sun Mar 02, 2008 8:22 am

Hello! And nice sunday..

I have no idea how to to implement focusable / selectable (android makes differences here) on GridView elements. What i mean, sounds simple:

There is a GridView, and i want Views to be added (works for me)
But, i also want them to be highlighted if i move the buttons on the phone (so, for mobile phones without touchscreen)

hm..
and help as highly welcomed.
alex

ps: the coolest thing would be a custom selection layer to draw on the selected item.
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Top

Postby plusminus » Sun Mar 02, 2008 11:07 am

Hello sommeralex,

you want a selection like this one :darrow: :?:
Image

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 Mar 02, 2008 11:29 am

exactly.. :roll:

i also set my views (they are all the same) to

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. setFocusable(true);
  3.  
  4.  
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


but this doesnt change anything.. myView extends linearLayout - mybe this causes some troubles.. ?
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Postby plusminus » Sun Mar 02, 2008 1:54 pm

Hello sommeralex,

I haven't done such a thing before, but I would start trying with :darrow: in your custom View:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.  
  3.         protected void onFocusChanged(boolean focused, int direction) {
  4.  
  5.                 // TODO Auto-generated method stub
  6.  
  7.                 super.onFocusChanged(focused, direction);
  8.  
  9.         }
Parsed in 0.032 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 sommeralex » Sun Mar 02, 2008 2:07 pm

thx for your answer.. the trouble is... there is nothing - no selection-rectangle at all..
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Postby plusminus » Sun Mar 02, 2008 4:21 pm

Hello sommeralex,

yes I understood.
But within that function you could alter the background-color of the LinearLayout and/or the Children.

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

Postby sommeralex » Sun Mar 02, 2008 4:35 pm

i got the "bug" - i dont know why - nor if it is really a bug, but for me, it sounds like one.

i added the adapter BEFORE adding any elements to the adapter itself. therefore, i had not the standard-selection function elements (views) have.

but anyway, thanx you very much for your suggestions..
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: No registered users and 17 guests