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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:37:56+00:00 2026-05-25T01:37:56+00:00

I am currently trying to work with Android ActionBar Sherlock on my Nexus One

  • 0

I am currently trying to work with Android ActionBar Sherlock on my Nexus One running Gingerbread 2.3.4.
I try to develop a FragmentList which enables me to create a Menu in this activity.
The menu should now consist out of “item1 – item4” However sometime later I want the menu to consists out of a custom made list.

However, whenever I try to execute my App it force closes for some reason or another.

This is the layout file:

<?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"
android:paddingLeft="0dip"
android:background="@drawable/bg">
<TextView 
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hauptmenü"
android:background="@drawable/custom_bg_title"
android:padding="5dip"
android:gravity="center"
android:textStyle="bold"
android:height="30px"
 />

<fragment class="com.w..TitlesFragment"
        android:id="@+id/titles" android:layout_weight="1"
        android:layout_width="0px"
        android:layout_height="match_parent" />


</LinearLayout>

This is the codefile of the activity

package com.;

import android.app.ListFragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import android.support.v4.view.Menu;
import android.support.v4.view.MenuItem;
import android.support.v4.view.SubMenu;
import android.support.v4.view.Window;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class wcw_realActivity extends FragmentActivity implements OnItemClickListener {


private static final String[] items ={"item1","item2","item3","item4"};
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    SubMenu subMenu1 = menu.addSubMenu("Action Item");
        subMenu1.add("Sample");
        subMenu1.add("Menu");
        subMenu1.add("Items");

    MenuItem subMenu1Item = subMenu1.getItem();
        subMenu1Item.setIcon(R.drawable.ic_title_share_default);
        subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);          

    return super.onCreateOptionsMenu(menu);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_ACTION_BAR);        
    setContentView(R.layout.main);                       
}   

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Log.i("FragmentList", "Item clicked: "+ id);
}

public static class TitlesFragment extends ListFragment {
    boolean mDualPane;
    int mCurCheckPosition = 0;

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

        // Populate list with our static array of titles.
        setListAdapter(new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1,
                items));

        if (savedState != null) {
            // Restore last state for checked position.
            mCurCheckPosition = savedState.getInt("curChoice", 0);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("curChoice", mCurCheckPosition);
    }

    @Override
    public void onListItemClick(ListView l, View v, int pos, long id) {
        Log.i("FragmentList", "Item clicked: "+ id);
    }

}

}

I suspect that I initialize the fragment on a bad way – which would probably explain that the App crashes every time.

When I exclude the “fragment” Tag out of my app it works just fine.

It would be great if someone knows a solution for that particular problem.

Here is the logfile

  • 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-25T01:37:57+00:00Added an answer on May 25, 2026 at 1:37 am

    ListFragment (or any other Fragment) is not available in Gingerbread by default. You might be compiling against Honeycomb which is why it compiles but crashes when run. Use the compatibility package to use Fragments in older versions of Android. Also, make sure you have your minSdkVersion set to the right one.

    If you’re already using the compatibility package, maybe you are not including it correctly (since the ListFragment class cannot be found)?

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

Sidebar

Related Questions

I'm currently trying to develop an encryption app for Android using ECDH and BouncyCastle.
I'm trying to develop an ebook reader(for mobile devices) which is platform independent. Currently
I ask this because I am currently trying to work out my own technique,
Hey all, here is the issue I am currently trying to work through. We
I'm currently trying to get ActiveAdmin to work on a model of mine but
Erlang version: R13B01 Currently I'm struggling trying to make Erlang work with SSL. The
I'm trying to update my old Android app to work correctly on Android 4.0.
I'm trying to make work this example from http://developer.android.com/resources/tutorials/views/hello-timepicker.html , no errors while compiling
I'm currently trying out the google's various android examples at http://developer.android.com/guide/tutorials/views/hello-spinner.html BUT I can't
I'm currently working on a project which involves optical character recognition in Android and

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.