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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:10:24+00:00 2026-06-07T12:10:24+00:00

I am developing an android application for both tablet and phone using fragments. I

  • 0

I am developing an android application for both tablet and phone using fragments. I was following the tutorial http://www.vogella.com/articles/Android/article.html#fragments_tutorial and created my own base adapter class. The basic idea of the implementation is the mainactivity must produce a gridview and when click on the image on the gridview it must open a new activity on phone and on tablet we must simultaneously view the two activites.

But somehow I am not able to run the application. It is being crashed while I start, leaving runtime errors. I am new to android development working on this problem from several weeks. Please help me.Thanks in advance.

Please find below my classes in the application

GridFragment.class

public class GridFragment extends Fragment{
@Override
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.gridview,container,false);
GridView gridView = (GridView) view.findViewById(R.id.gridView);
gridView.setAdapter(new EveryoneAdapter(view.getContext()));
// uses the view to get the context instead   of getActivity().
    return view;
}
 public void onActivityCreated(Bundle savedInstanceState) {
     super.onActivityCreated(savedInstanceState);
 }
}

EveryoneAdapter.class

public class EveryoneAdapter extends BaseAdapter {
private Context mContext;

public EveryoneAdapter(Context c) {
    mContext = c;
}

public int getCount() {
    return mThumbIds.length;
}

public Object getItem(int position) {
    return null;
}

public long getItemId(int position) {
    return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(final int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {  // if it's not recycled, initialize some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);
        imageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
              Log.d("onClick","position ["+position+"]");
            }

          });
    } else {
        imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);
    return imageView;
}

// references to our images
private Integer[] mThumbIds = {
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7
};
}

DetailFragment.class

public class DetailFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("Test", "hello");
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.details, container, false);
    return view;
}

  }

DetailActivity.class

public class DetailActivity extends Activity {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Need to check if Activity has been switched to landscape mode
    // If yes, finished and go back to the start Activity
    if (getResources().getConfiguration().orientation == 
            Configuration.ORIENTATION_LANDSCAPE) {
        finish();
        return;
    }

    setContentView(R.layout.details_activity_layout);

}
  }

And my MainActivity.class

public class MainActivity extends Activity {

/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}
 }

Layout files are as follows

main.xml(Landscape mode)

<?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="horizontal" >

<fragment
    android:id="@+id/gridFragment"
    android:layout_width="150dip"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    class="com.fxpal.unity.android.GridFragment" ></fragment>

<fragment
    android:id="@+id/detailFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.fxpal.unity.android.DetailFragment" >
    <!-- Preview: layout=@layout/details -->
</fragment>

details.xml

<?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="horizontal" >

<fragment
    android:id="@+id/gridFragment"
    android:layout_width="150dip"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    class="com.fxpal.unity.android.GridFragment" ></fragment>

<fragment
    android:id="@+id/detailFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.fxpal.unity.android.DetailFragment" >
    <!-- Preview: layout=@layout/details -->
</fragment>

details_activity_layout.xml

<?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="horizontal" >

<fragment
    android:id="@+id/gridFragment"
    android:layout_width="150dip"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    class="com.fxpal.unity.android.GridFragment" ></fragment>

<fragment
    android:id="@+id/detailFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.fxpal.unity.android.DetailFragment" >
    <!-- Preview: layout=@layout/details -->
</fragment>

</LinearLayout>

main.xml(portrait mode)

<?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="horizontal" >

<fragment
    android:id="@+id/gridFragment"
    android:layout_width="150dip"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    class="com.fxpal.unity.android.GridFragment" ></fragment>

<fragment
    android:id="@+id/detailFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.fxpal.unity.android.DetailFragment" >
    <!-- Preview: layout=@layout/details -->
</fragment>

</LinearLayout>

And my Manifest.xml is

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fxpal.unity.android"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="List of Mobiles"
        android:name=".MainActivity" >
         <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DetailActivity"
        android:label="@string/app_name" >
    </activity>
</application>

My error log is below

07-10 04:06:06.625: E/AndroidRuntime(1393): FATAL EXCEPTION: main
07-10 04:06:06.625: E/AndroidRuntime(1393): java.lang.RuntimeException: Unable to start activity      ComponentInfo{com.fxpal.unity.android/com.fxpal.unity.android.MainActivity}: android.view.InflateException:   Binary XML file line #7: Error inflating class fragment
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.os.Looper.loop(Looper.java:137)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.ActivityThread.main(ActivityThread.java:4424)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at java.lang.reflect.Method.invokeNative(Native Method)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at java.lang.reflect.Method.invoke(Method.java:511)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at dalvik.system.NativeStart.main(Native Method)
07-10 04:06:06.625: E/AndroidRuntime(1393): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.Activity.setContentView(Activity.java:1835)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at com.fxpal.unity.android.MainActivity.onCreate(MainActivity.java:14)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.Activity.performCreate(Activity.java:4465)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-10 04:06:06.625: E/AndroidRuntime(1393):     ... 11 more
07-10 04:06:06.625: E/AndroidRuntime(1393): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.fxpal.unity.android.ListFragment: make sure class name exists, is public, and has an empty constructor that is public
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.Fragment.instantiate(Fragment.java:581)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.Fragment.instantiate(Fragment.java:549)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.Activity.onCreateView(Activity.java:4235)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)
07-10 04:06:06.625: E/AndroidRuntime(1393):     ... 21 more
07-10 04:06:06.625: E/AndroidRuntime(1393): Caused by: java.lang.ClassNotFoundException: com.fxpal.unity.android.ListFragment
07-10 04:06:06.625: E/AndroidRuntime(1393):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-10 04:06:06.625: E/AndroidRuntime(1393):     at android.app.Fragment.instantiate(Fragment.java:571)
07-10 04:06:06.625: E/AndroidRuntime(1393):     ... 24 more
  • 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-06-07T12:10:25+00:00Added an answer on June 7, 2026 at 12:10 pm

    Either you haven’t copy-pasted all the layout files you’re using, or you’re loading the wrong layout file somewhere. The stacktrace clearly mentions that at some point it tries to load the fragment with fully qualified class name com.fxpal.unity.android.ListFragment from a layout file. However, There isn’t such a ListFragment class in the snippets you provided.

    Do a search in your project for com.fxpal.unity.android.ListFragment and correct any references.

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

Sidebar

Related Questions

I am developing an application using phonegap for both ios and android. My application
My team and I are currently developing an application for both Android and iOS
I'm developing android application for CAR usage and I need that in phone or
I'm developing an application both for Iphone and Andriod using Phonegap. I came up
I am developing an application for both Android and iPhone and I am having
I am developing android application. I am finding following problem which isdisplayed by output
I'm developing an Android Application for a tablet (1024x768). I searched and find some
I am developing an android game application played using bluetooth. While searching for bluetooth
i am developing android application using Geocoder services, I have an application where I
Presently I am developing Android application for Samsung galaxy tab. I am using default

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.