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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:01:18+00:00 2026-05-29T11:01:18+00:00

So I have an Activity which has a FragmentPagerAdapter and inside each fragment I

  • 0

So I have an Activity which has a FragmentPagerAdapter and inside each fragment I have two other Fragment (here called a and b). Fragment a is a ListFragment, while fragment b is just a normal fragment that displays the value.

There are two issues here…

1.) I cannot grab views from the Activity in Fragment B

2.) If I comment out the grabs, instead of showing Fragment A on a phone followed by B once an item is selected, IT shows both on the same viewpager.

However, I can’t seem to load my layouts properly. However if I remove b everything seems to work fine…

The Activity loads the following layout…

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
    <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/indicator"
        android:padding="10dip"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        />
    <android.support.v4.view.ViewPager
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/mainpager"/>
</LinearLayout>

My First Fragment looks as follows

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <fragment android:name="com.gleason.apa.fragment.BarListFragment"
            android:id="@+id/bar_list_fragment"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent" />
    <fragment android:name="com.gleason.apa.fragment.BarEditFragment"
            android:id="@+id/bar_edit_fragment"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="match_parent" />
</LinearLayout>

Fragment A

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Bar Name: " />
        <TextView
            android:id="@+id/bar_name_list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Address: " />

        <TextView
            android:id="@+id/bar_address_list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>

Fragement B

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Bar Name" />
        <EditText
    android:id="@+id/bar_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="Name"
        />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Address" />

        <EditText
            android:id="@+id/bar_address"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:inputType="text"
            android:hint="Address"/>
    </LinearLayout>
<Button
    android:id="@+id/submitBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:text="Add Game"/>
</LinearLayout>

However, when I try to compile and run I get the following…

android.view.InflateException: Binary XML file line #6: Error inflating class fragment
java.lang.NullPointerException

Any ideas?

UPDATE:

So the null pointer exception comes from BarEditFragment…

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    ....
    name = (EditText) activity.findViewById(R.id.bar_name);
    address = (EditText) activity.findViewById(R.id.bar_address);
Button submit = (Button) activity.findViewById(R.id.submitBar);
}

All of those come back null.

Also if I remove those, the fragments show both, even on my phone. So it shows two small fragments side by side, instead of the 2 “screens” like it is supposed to.

Also this did not work…

activity.getFragmentManager().findFragmentById(R.id.bar_edit_fragment).getView().findViewById(R.id.bar_name);
  • 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-29T11:01:18+00:00Added an answer on May 29, 2026 at 11:01 am

    The thing I was missing is you need to create layouts that tell if it is single or dual pane. The best way to figure this out is to use the NewsReader example as a template.

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

Sidebar

Related Questions

I have an activity which uses two Loaders. Each of them returns different type
I have an activity which has two edit text fields: one for the title
Here's the scenario I have an activity(A) which has a button and textview. I
I have an activity which has some text views and other data to be
In my Android application, I have a fragment activity which it has a progressbar.
I have an app which has a main activity that calls other activities on
I have one activity Select which has four buttons and other activity Result. Now
i have a main Activity called Main which has onActivityResult Method. protected void onActivityResult(int
I have an Activity which has two different layouts based on grid view and
I have a activity which has a button and 2 autocomplete widget. for the

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.