Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7639205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:21:37+00:00 2026-05-31T08:21:37+00:00

I’m trying to make a viewpager that has editable text, but I don’t want

  • 0

I’m trying to make a viewpager that has editable text, but I don’t want the viewpager to scroll when a text box is being edited. I’m trying to disable the scrolling by using the beginFakeDrag and endFakeDrag functions of the viewpager which causes the viewpager to ignore all touch events. For some reason if you call beginFakeDrag followed by endFakeDrap it works fine, but when separated it throws the following error:

03-08 17:54:00.511: E/AndroidRuntime(31362): FATAL EXCEPTION: main
03-08 17:54:00.511: E/AndroidRuntime(31362): java.lang.NullPointerException
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.support.v4.view.ViewPager.endFakeDrag(ViewPager.java:1683)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at gtg.gis.RequestActivity$2.onFocusChange(RequestActivity.java:115)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.view.View.onFocusChanged(View.java:2742)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.widget.TextView.onFocusChanged(TextView.java:7080)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.view.View.clearFocus(View.java:2639)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.view.ViewGroup.clearFocus(ViewGroup.java:522)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.view.View.setFlags(View.java:4645)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.view.View.setVisibility(View.java:3116)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at gtg.gis.RequestActivity$1.onClick(RequestActivity.java:95)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.view.View.performClick(View.java:2485)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.view.View$PerformClick.run(View.java:9089)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.os.Handler.handleCallback(Handler.java:587)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.os.Looper.loop(Looper.java:130)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at android.app.ActivityThread.main(ActivityThread.java:3806)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at java.lang.reflect.Method.invokeNative(Native Method)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at java.lang.reflect.Method.invoke(Method.java:507)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-08 17:54:00.511: E/AndroidRuntime(31362):    at dalvik.system.NativeStart.main(Native Method)

Here is my code.

        commentBox.setOnFocusChangeListener(new EditText.OnFocusChangeListener()
        {

            public void onFocusChange(View v, boolean hasFocus)
            {
                if (hasFocus)
                {
                    InputMethodManager mgr = (InputMethodManager) getContext().getSystemService(
                            Context.INPUT_METHOD_SERVICE);
                    mgr.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
                    _viewPager.beginFakeDrag();
                    return;
                }

                _viewPager.endFakeDrag();
                InputMethodManager mgr = (InputMethodManager) getContext().getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                mgr.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:21:38+00:00Added an answer on May 31, 2026 at 8:21 am

    Please check out my answer to another question about disabling the swiping of ViewPager: How do disable paging by swiping with finger in ViewPager but still be able to swipe programmatically?

    I’d just enhance it to have a boolean:

    private boolean mDisablePaging;
    

    Then add a getter/setter if you need it for that boolean.

    Then enhance onInterceptTouchEvent:

    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {
        // Don't allow swiping to switch between pages if we disabled it
        if (mDisablePaging) {
           return false;
        }
    
        // Otherwise, do the normal behavior 
        return super.onInterceptTouchEvent(arg0);
    }
    

    Then just set mDisablePaging to true when you detect that the user is editing the text box.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.