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 6255233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:19:38+00:00 2026-05-24T14:19:38+00:00

I am using the compatibility package and I have a Fragment who returns a

  • 0

I am using the compatibility package and I have a Fragment who returns a WebView in onCreateView. The problem is if the fragment isn’t added during onCreate of the Activity then when a textbox is clicked inside of the WebView the softkeyboard is not displayed. If the device is rotated after the the custom web fragment has been added, recreating the activity, then the softkeyboard is displayed when clicking on a text field.

Just to be clear Here are the two different scenarios

public void onCreate(Bundle state){
   if(state == null){
      WebFragment web = new WebFragment();
      getSupportFragmentManager.beginTransaction().add(android.R.id.content, web).commit();
   }
}



public void onClick(View v){
      WebFragment web = new WebFragment();
      getSupportFragmentManager.beginTransaction().add(android.R.id.content, web).commit();
}

In the first case when adding the fragment during the Activity onCreate method then the WebView contained in the fragment works as it should when text fields are pressed. However, in the second example nothing happens when clicking a text field in the webview unless you rotate the device after the webview had been displayed. Can someone offer up a solution, if I have to create a new activity for my fragment to work properly it sorta beats the purpose of the fragment in the first place.

  • 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-24T14:19:41+00:00Added an answer on May 24, 2026 at 2:19 pm

    Add this to the onCreateView method of the Fragment

    webview.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                case MotionEvent.ACTION_UP:
                    if (!v.hasFocus()) {
                        v.requestFocus();
                    }
                    break;
            }
            return false;
        }
    });  
    

    Tested with android 2.3.3 and 3.2.0.

    Based on issue #7189 and StackOverflow

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

Sidebar

Related Questions

I am using the Android Compatibility Package with API Level 10. I have a
Me used Fragment of Android Compatibility Package, using the android-support-v4.jar . But I can't
I'm using fragments in my Android application using the compatibility package. I have tested
Using the compatibility package to target 2.2 using Fragments. After recoding an activity to
I have a program in C using Solaris with VERY ancient compatibility it seems.
I want to implement an AsyncTaskLoader in my project using the Compatibility Package, so
I have built an app using jQuery mobile. Apart of some compatibility issues across
This is a rather random problem. I'm using CSS3Pie to handle CSS3 compatibility in
My app is currently using the Fragments/v4 compatibility package to support Android versions all
I have an app that uses fragments.I'm using backward compability package with Android 2.2.

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.