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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:16:29+00:00 2026-06-05T15:16:29+00:00

I am using Sectioned List in my activity which extends ListActivity but now as

  • 0

I am using Sectioned List in my activity which extends ListActivity
but now as i need to add Actionbar to this activity so i cant use ListActivity here.
So i am trying to use ListView for the same.
But i am not getting how to set adapter to the Listview.
Because i need to set custom adapter used for SectionedListView.
But when i used it for simple ListView it gives NullPointer Exception.
i had wasted more than enough time for it
please help me.

this is the xml file of ListView

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

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>

and this is the adapter used for (ListActivity).


public class EntryAdapter extends ArrayAdapter<Item> {

    private Context context;
    private ArrayList<Item> items;
    private LayoutInflater vi;
    private ImageDownloader mImageDownloader;
    public EntryAdapter(Context context,ArrayList<Item> items, ImageDownloader mImageDownloader) {
        super(context,0, items);
        this.context = context;
        this.items = items;
        vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.mImageDownloader = mImageDownloader;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        Log.v("position in entry adapter", ""+position);

        final Item i = items.get(position);
        if (i != null) {
            if(i.isSection()){
                SectionItem si = (SectionItem)i;
                v = vi.inflate(R.layout.list_item_section, null);

                v.setOnClickListener(null);
                v.setOnLongClickListener(null);
                v.setLongClickable(false);

                final TextView sectionView = (TextView) v.findViewById(R.id.list_item_section_text);
                sectionView.setText(si.getTitle());
            }else{
                EntryItem ei = (EntryItem)i;
                v = vi.inflate(R.layout.list_item_entry, null);
                final TextView title = (TextView)v.findViewById(R.id.list_item_entry_title);
                final TextView subtitle = (TextView)v.findViewById(R.id.list_item_entry_summary);
                final ImageView cat_icon = (ImageView)v.findViewById(R.id.category_icon);
                final ImageView channel_icon = (ImageView)v.findViewById(R.id.channel_icon);
                if (title != null) 
                    title.setText(ei.title);
                if(subtitle != null)
                    subtitle.setText(ei.subtitle);
                if(cat_icon != null)
                {
                    if(ei.catIcon != null)
                        cat_icon.setImageBitmap(ei.catIcon);
                    else
                        cat_icon.setVisibility(View.INVISIBLE);
                }
                if(channel_icon !=null)
                {
                    if(ei.url != null)
                    {
                        mImageDownloader.download(ei.url,channel_icon);
                        Log.v("url in adapter", ei.url);
                    }
                    else
                        channel_icon.setVisibility(View.INVISIBLE);
                }
            }
        }
        return v;
    }


}



mList = (ListView) findViewById(R.id.list);

EntryAdapter adapter = new EntryAdapter(this, items, mImageDownloader);
        mList.setAdapter(adapter);
        mList.setOnItemClickListener(this);

Thanks
Mahaveer.

  • 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-05T15:16:30+00:00Added an answer on June 5, 2026 at 3:16 pm

    What you need to do for changing a class that extends ListActivity to Activity,

    1.) Extend your Class with Activity instead of ListActivity

    2.) Change the id of ListView in xml from @android:id/list to @+id/your_listview

    3.) find the instance of ListView declared in xml using

    ListView your_listview = (ListView)findViewById(R.id.your_listview);  
    

    4.) Set the Adapter using,
    your_listview.setAdapter(adapter);

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

Sidebar

Related Questions

I'm trying to make a LazyList EndlessList but using a sectioned adapter...The sections will
I tried to list imported DLL of PE file using following code, but it
I'm trying to convert a sectionned table into a flat list using this function
I am using TIdTCPClient to get a file list all works well but when
HI Guyz i have created a sectioned custom listview using baseadapter its working fine
In gcc doc one reason is given for using section . This reason is
I want to create section without numbers using the command \section*{Section Name}, but doing
Using this tutorial at section 5.5, I attempted to Assign the 'celsius' string attribute
I'm using SeperatedListAdapter available here: http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/ but I want to create a list with
I currently have an ordered list that I want to markup using the new

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.