Android焦点相关问题

时间:2012-06-06 12:48:53

标签: android relativelayout

我有一个RelativeLayout我有5个按钮,我在屏幕超时后隐藏了这个RelativeLayout(如果没有用户活动),当用户做了一些活动然后我把它设置为可见。

但问题是,当我将RelativeLayout设置为不可见时,它会从其子项中移除焦点,当我将其设置为可见时,它只会将焦点设置为第一个孩子。

当我将其设置为可见或不可见时,我需要将焦点设置为要保留的RelativeLayout之前关注的子项。

感谢。

1 个答案:

答案 0 :(得分:1)

//Global Variable.. 
  View v;


//beore you hiding the buttons 
v = getCurrentFocus ();




//after you showing the buttons 
 if(null!=v && v. isFocusable ())
    v.requestFoucs();