如何使用 ViewPager android 禁用或隐藏键盘上的左右箭头

Arj*_*ini 1 java android android-viewpager

我正在尝试keyboard使用此代码禁用左右两侧的功能,但viewPager按左右键会button更改寻呼机的状态。

edComment.setOnEditorActionListener(
    new EditText.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

        if (actionId == EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS
                || actionId == EditorInfo.IME_FLAG_NAVIGATE_NEXT
                || actionId == EditorInfo.IME_ACTION_PREVIOUS
                || actionId == EditorInfo.IME_ACTION_NEXT
                ) {


            return false;


        }
        // Return true if you have consumed the action, else false.
        return false;
    }
});
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

小智 6

您可以扩展 ViewPager 并覆盖这样的arrowScroll方法:

public class Wizard extends ViewPager {
    @Override
    public boolean arrowScroll(int direction) {
        // Never allow pressing keyboard arrows to switch between pages
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)