您可以扩展ListView类并覆盖requestLayout()方法.当ListView完成更新并窃取焦点时,将调用该方法.因此,在此方法的最后,您可以将焦点返回到TextView.
public class ExampleListView extends ListView {
private ListViewListener mListener;
public ExampleListView(Context context) {
super(context);
}
public ExampleListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ExampleListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void requestLayout() {
super.requestLayout();
if (mListener != null) {
mListener.onChangeFinished();
}
}
public void setListener(ListViewListener listener) {
mListener = listener;
}
public interface ListViewListener {
void onChangeFinished();
}
}
并将侦听器设置为此ListView
ExampleListView listView = (ExampleListView) view.findViewById(R.id.practice_exercises_list);
listView.setListener(new ExampleListView.ListViewListener() {
@Override
public void onChangeFinished() {
txtCurrentFocus.requestFocus();
}
});