Android 将焦点从视图组(ListView项目)移到视图(按钮)

Android 将焦点从视图组(ListView项目)移到视图(按钮),android,listview,android-view,viewgroup,android-viewgroup,Android,Listview,Android View,Viewgroup,Android Viewgroup,我有一个包含“N”个项目的列表视图,列表中的每个itemViewGroup都有一些视图,如图像视图、文本视图和一些按钮,如下图所示 我的要求是,在ListView中滚动时,如果我在D-Pad中按左/右键,则最左侧或最右侧的按钮应聚焦,而整个列表视图项的聚焦应消失 我尝试过android:nextFocusDown的xml和SetNextFocusDownidit 但不起作用 我是否需要在xml/java中添加其他参数 注意:我的应用程序/设备中有D-pad。我通过创建“CustomListVie

我有一个包含“N”个项目的列表视图,列表中的每个itemViewGroup都有一些视图,如图像视图、文本视图和一些按钮,如下图所示

我的要求是,在ListView中滚动时,如果我在D-Pad中按左/右键,则最左侧或最右侧的按钮应聚焦,而整个列表视图项的聚焦应消失

我尝试过android:nextFocusDown的xml和SetNextFocusDownidit

但不起作用

我是否需要在xml/java中添加其他参数

注意:我的应用程序/设备中有D-pad。

我通过创建“CustomListView”实现了这一点。 我在CustomListView中扩展了ListView

我覆盖了onKeyDown和onkeydup,并将值设置为和

希望我的解决方案能帮助你

public class CustomListView extends ListView
{
public CustomListView(Context context)
{
    super(context);
}

public CustomListView(Context context, AttributeSet attrs)
{
    super(context, attrs);
}

public CustomListView(Context context, AttributeSet attrs, int defStyleAttr)
{
    super(context, attrs, defStyleAttr);
}

public CustomListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
{
    super(context, attrs, defStyleAttr, defStyleRes);
}