4

I developed a software for my cerebral palsy girl. She uses it in our tablet to "communicate" with me and my wife.

It's pretty nice. It's a bunch of ImageButtons created "on-the-fly". I mean just inflating XML code.

Here is an image sample:

Sample image from my software

I created this just for my daughter.

I have a friend with Amyotrophic lateral sclerosis (ALS). It's a terrible degerative disease. He can move just one finger and I would like to make possible for him to use the same software.

In order to do that, I must "iterate" through each ImageButton and when the one he wants is focused, he will "click" in a mouse to activate it.

I tried to use what is described in here:

http://developer.android.com/guide/topics/ui/accessibility/apps.html

But it didn't work. Any ideas on how to do this? This would be REALLY useful for my ALS friend.

Here is how I create the ImageButtons:

btn = (ImageButton) LayoutInflater.from(
getBaseContext()).inflate(
R.layout.imagebuttonstyle, fl, false);

I just use the "OnTouch" event to handle clicks. The imagebuttonstyle is just a XML file declaring an ImageButton.

So, what do you guys think? How can I iterate through items ensuring that when the one he wants is in focus, it will be activated when my friend clicks his mouse? I can easily cycle through all items, but this doesn't ensure that this item will be activated by his mouse.

Any help is very appreciatted!

Carlos Pereira
  • 1,914
  • 6
  • 24
  • 35
  • Hi Carlos, the Android widgets are focusable already. It seems to me that you're using a custom appearance for `ImageButton`s, so in order to handle the focused state (i.e., show the button in a different visual appearance) you must provide appropriate drawables for the button. I don't think you need to worry about handling in code the focused state. I believe you just need to provide `onClickListener` to the button without worrying about which control is focused. If you need a proper answer with some code, just let me know. Best regards. – davidcesarino Jun 19 '12 at 05:33
  • 1
    ps.: by the way, it's David, from your "One Dollar for a Dream" campaign! :) Nice to see you here with such a nice goal. – davidcesarino Jun 19 '12 at 05:35
  • I think he was saying that the mouse wouldn't be moved over the button, only that it would be clicked somewhere on the screen. The button focus would be changed by some other means. Therefore, I don't think he just wants to use an OnClickListener on each specific button. I don't know, maybe I misunderstood. – thomas.cloud Jun 19 '12 at 05:44
  • thomas.cloud, you are right. ImageButtons must be focused in a regular interval one by one. Then, it doesn't matter where the cursor is, the one focused must be activated when user clicks the mouse button – Carlos Pereira Jun 19 '12 at 11:12

1 Answers1

0

Could you use an OnClickListener? See this question, I think it is going in a direction that you could go. Alternatively you could make your entire layout clickable. Then you could use isFocused() to determine which item to select. For example:

LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linear_layout);
linearLayout.setOnClickListener(this);

@Override
public void onClick(View view){
   if (view == linearLayout){
      if (mingua.isFocused()){
          //mingua action 
      } else if (pao.isFocused()){
          //pao action
      } //etc...
   }

}

I'm not positive if you can set a linear layout to have a click listener, but if that doesn't work, you could add an invisible button covering the whole screen as a background layer and set an onClickListener on that. Good luck.

Community
  • 1
  • 1
thomas.cloud
  • 881
  • 13
  • 30