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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:12:05+00:00 2026-05-31T14:12:05+00:00

Ive been trying to get a listview working within a fragment all day. I

  • 0

Ive been trying to get a listview working within a fragment all day. I dont know why but for some reason the way Im trying to do it, it just never wants to inflate the view. Im using actionbarsherlock if that makes a difference but I dont think so. Heres the class where my layout fails:

 public class GraffSearch extends FragmentActivity implements ActionBar.TabListener{

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    setContentView(R.layout.searchlayout);//<-------------fails here

    final ActionBar ab = getSupportActionBar();

    for (int i = 1; i < 4; i++) {
        ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this));
    }


    ab.show();
    if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_TABS) {
        ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }



}

@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
    // TODO Auto-generated method stub

}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    //Toast.makeText(this, "tabs work "+tab.getPosition()+" user id is "+avrid, Toast.LENGTH_LONG).show();
    SearchListFrag fragment = (SearchListFrag) getSupportFragmentManager().findFragmentById(R.id.searchfrag);
    //fragment.updateUrl(tab.getPosition(), avrid);

}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    // TODO Auto-generated method stub

}

}

and heres the layout were I call my fragment.

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


<ListFragment
    android:id="@+id/searchfrag"
    android:layout_width="0dip"
    android:layout_height="match_parent"
    android:name="graffit.main.SearchListFrag"
    android:layout_weight="1"></ListFragment>



</LinearLayout>

EDIT: my searchlistfrag class

public class SearchListFrag extends Fragment{

ListView markList;

public SearchListFrag(){};

 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
    markList = (ListView) inflater
               .inflate(R.id.searchlist, container, false);//<----------Fails Here
     markList.setAdapter(new OrderAdapter(
             MixView.mixContext.getBaseContext(),
             R.layout.searchinnerlistlayout, 
             MixView.dataView.dataHandler.markerList ));


    // return inflater.inflate(R.layout.searchlistlayout, container, false);
    return markList;            

    }


    @Override
    public void onPause() {

       super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();

    }

    public void updateUrl(int tab, String avrid) {

    }

    private class OrderAdapter extends ArrayAdapter<Marker> {

        private ArrayList<Marker> marks;

        public OrderAdapter(Context context, int textViewResourceId, ArrayList<Marker> items) {
                super(context, textViewResourceId, items);
                this.marks = items;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.searchinnerlistlayout, null);
                }
              //  Order o = items.get(position);
                if (marks.get(position) != null) {
                        TextView title = (TextView) v.findViewById(R.id.title);
                        //TextView description = (TextView) v.findViewById(R.id.description);
                        if (title != null) {
                              title.setText("Title: "+marks.get(position).getTitle());                            }
                        //if(description != null){
                        //  description.setText("Description: "+ +marks.get(position).get);
                       // }
                        ImageView icon = (ImageView) v.findViewById(R.id.markimage);
                        icon.setImageBitmap(marks.get(position).getBitmap());
                }

                return v;
        }
}   
}

EDIT: my searchlistlayout layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     >
 <ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:name="@+id/searchlist"></ListView> //<----this is the id i use that fails

 </LinearLayout>

Ive tried a few different setups going back and forth from using a regular fragment and a listfragment with the same result. Heres the logcat.

EDIT: New log cat

03-18 15:34:45.939: E/AndroidRuntime(20704): FATAL EXCEPTION: main
03-18 15:34:45.939: E/AndroidRuntime(20704): java.lang.RuntimeException: Unable to start activity ComponentInfo{graffit.main/graffit.main.GraffSearch}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.app.ActivityThread.access$1500(ActivityThread.java:124)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.os.Looper.loop(Looper.java:130)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.app.ActivityThread.main(ActivityThread.java:3806)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at java.lang.reflect.Method.invokeNative(Native Method)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at java.lang.reflect.Method.invoke(Method.java:507)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at dalvik.system.NativeStart.main(Native Method)
03-18 15:34:45.939: E/AndroidRuntime(20704): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.support.v4.app.FragmentActivity.setContentView(FragmentActivity.java:421)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at graffit.main.GraffSearch.onCreate(GraffSearch.java:16)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
03-18 15:34:45.939: E/AndroidRuntime(20704):    ... 11 more
03-18 15:34:45.939: E/AndroidRuntime(20704): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f050068 type #0x12 is not valid
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:1912)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.content.res.Resources.getLayout(Resources.java:746)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at graffit.main.SearchListFrag.onCreateView(SearchListFrag.java:28)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:845)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1058)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1156)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:660)
03-18 15:34:45.939: E/AndroidRuntime(20704):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
03-18 15:34:45.939: E/AndroidRuntime(20704):    ... 19 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-05-31T14:12:06+00:00Added an answer on May 31, 2026 at 2:12 pm

    The fragment import in your layout is wrong. Fragments are added to a layout with the <fragment> tag. Other than with Views you don’t name the tag after the fully-qualified class name. The error occurs because Android tries to inflate a View with the type ‘ListFragment’, that doesn’t exist.

    Try:

    <fragment
        android:id="@+id/searchfrag"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:name="graffit.main.SearchListFrag"
        android:layout_weight="1"></fragment>
    

    The <fragment> has to be in lower case, <Fragment> won’t work too.

    Your mixing some things up.

    1) The onCreate method of the fragment has to inflate the whole layout of the fragment. After inflating the Fragment layout you can get the ListView.

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View contentView = inflater.inflate(R.id.searchlist, container, false);     
        markList = (ListView) contentView.findViewById(R.id.searchlist);
        markList.setAdapter(new OrderAdapter(MixView.mixContext.getBaseContext(), R.layout.searchinnerlistlayout, MixView.dataView.dataHandler.markerList));
    
        return contentView;
    }
    

    2) You did not define the id of the ListView, you defined its name. Change the layout:

     <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         >
     <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:id="@+id/searchlist"></ListView> 
     </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been trying to get this solved for quite a few hours, but I
Ive been trying to get an example Web Service working using SpringWS and Tomcat5.5
Hi guys ive been trying to get smooth scrolling working on my anchors for
Ive been trying to write my first Blackberry Adobe Flex application but get the
Ive been trying to debug this for hours but I was unable to get
I've been trying to get into F# on and off for a while but
I've been trying to get this code to work for hours! All I need
I've been trying to get the UNIQUE constraint placed on some attributes I have
I've been trying to get to grips with Core Data and I'm having some
I've been trying to get setup with Ruby on Rails today, but I think

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.