Problem: Remote control button selected options have a marquee effect, but the mouse event, there is no marquee effect
Solving process: Rewrite a class to inherit TextView, always get focus, no. Even if I onhoverlistener inside Onhover and got the focus on TextView, it still doesn't work.
Workaround: Finally rewrite a class to inherit TextView, get focus forever, and call setselected (true) on TextView.
public class Marqueetextview extends TextView {public marqueetextview (Context con) { super (con); } Public Marqueetextview (context context, AttributeSet Attrs) { Super (context, attrs); } Public Marqueetextview (context context, AttributeSet attrs, int defstyle) { Super (context, attrs, Defstyle); } @Override Public boolean isFocused () { return true; } @Override protected void Onfocuschanged (Boolean focused, int direction, Rect previouslyfocusedrect) { }}
<com.jrm.localmm.ui.view.marqueetextview android:id= "@+id/listnametextview" android:layout_width= " Wrap_content " android:layout_height=" wrap_content " android:ellipsize=" marquee " android:gravity=" Left " android:layout_marginleft=" 2dip " android:marqueerepeatlimit=" Marquee_forever " android: Singleline= "true" android:textcolor= "@android: Color/white" android:textsize= "15sp" > </ Com.jrm.localmm.ui.view.marqueetextview>
Holder.settingOptionTextView.setSelected (TRUE);
In addition summarizes the next under an TV mouse, remote key events:
First of all, for selector, only the remote button under TV can trigger all events: focus,selected,press
<?xml version= "1.0" encoding= "UTF-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "><!--no focus Yiwen--><item android:state_focused=" false "android:state_selected=" false "android:state _pressed= "false" android:drawable= "@android: color/transparent"/><item android:state_focused= "false" Android : State_selected= "true" android:state_pressed= "false" android:drawable= "@drawable/list_foucs"/><!--focus Yiwen-- ><item android:state_focused= "true" android:state_selected= "false" Android:state_pressed= "false" Android: drawable= "@drawable/list_foucs"/><item android:state_focused= "true" android:state_selected= "true" Android: State_pressed= "false" android:drawable= "@drawable/list_foucs"/><!--Press down Yiwen--><item Android:state_ Pressed= "true" android:drawable= "@drawable/list_foucs"/></selector>
The press event can be triggered by the mouse only when clicked.
As for how to imitate the button event under mouse control to select an item, the background image changes, can only indirectly by setting the item background image to achieve
Refresh the focus state of a ListView item public void refreshitemfocusstate (int index) { //TODO auto-generated m Ethod stub log.d (TAG, "refreshitemfocusstate index =" +index); Currentselecteditemview = Listview.getchildat (index); if (isenterlistviewlocation) { if (Oldselecteditemview! = null) Oldselecteditemview.setbackgroundresource ( R.drawable.button_normal); if (Currentselecteditemview! = null) Currentselecteditemview.setbackgroundresource (R.DRAWABLE.LIST_FOUCS); Oldselecteditemview = Currentselecteditemview; } }
[Android TV Button responds to]listview's TextView the problem of failure under mouse control