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!

4

1 回答 1

0

你可以使用OnClickListener吗?看到这个问题,我认为它正在朝着你可以去的方向发展。或者,您可以使整个布局可点击。然后您可以使用isFocused()来确定要选择的项目。例如:

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...
   }

}

如果您可以将线性布局设置为具有单击侦听器,我不肯定,但如果这不起作用,您可以添加一个覆盖整个屏幕的不可见按钮作为背景层,并在其上设置一个 onClickListener。祝你好运。

于 2012-06-19T04:35:19.463 回答