Iterations through ImageButtons giving Android focus

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

This is pretty good. This is a bunch of ImageButtons created on the fly. I mean just bloating the XML code.

Here is an example image:

Sample image from my software

I created this only for my daughter.

I have a friend with amyotrophic lateral sclerosis (ALS). This is a terrible degenerative disease. It can only move one finger, and I would like to make it possible to use the same software.

To do this, I have to "iterate" through each ImageButton, and when he wants to concentrate, he will "click" in the mouse to activate it.

I tried using what is described here:

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

But that did not work. Any ideas how to do this? This would be REALLY helpful for my friend ALS.

This is how I create ImageButtons:

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

I just use the OnTouch event to handle clicks. Imagebuttonstyle is simply an XML file declaring ImageButton.

So what do you guys think? How can I iterate over elements, ensuring that when the one he wants is in focus, it will be activated when my friend clicks on the mouse? I can easily navigate through all the elements, but this does not guarantee that this element will be activated with his mouse.

Any help is much appreciated!

+4
source share
1 answer

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

 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 sure if you can set a linear layout to listen for clicks, but if that doesn't work, you can add an invisible button that spans the entire screen as a background layer and set onClickListener. Good luck.

0
source

All Articles