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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:20:42+00:00 2026-06-08T15:20:42+00:00

I’m working on a port to Android of a previously released iOS project that

  • 0

I’m working on a port to Android of a previously released iOS project that I’ve recently finished. This app parses XML from a site and populates the text from the XML elements into a ListView. I have the XML parsing portion down with no problem. The problem I’m running into is with loading this data into the ListView. I have a Custom Adapter in place to handle the text and button that will populate on each row, but the app is crashing at the line where I set the adapter: lv.setAdapter(adap). The error is a Null Pointer Exception. Error and code below. I believe I’m missing a step with the ListView and the adapter. I’ve also verified that my ArrayList menuItems has data and is not null. Any input, guidance, or feedback I could get on this would be greatly appreciated.

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to startactivity 
ComponentInfo{tv.undignified.android/tv.undignified.android.Undignified}:     
java.lang.RuntimeException: Unable to start activity ComponentInfo{tv.undignified.android/ java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{tv.undignified.android/tv.undignified.android.Podcasts}: java.lang.NullPointerException

Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{tv.undignified.android/tv.undignified.android.Podcasts}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
at android.widget.TabHost.setCurrentTab(TabHost.java:323)
at android.widget.TabHost.addTab(TabHost.java:213)
at tv.undignified.android.Undignified.onCreate(Undignified.java:48)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

Main code:

public class Podcasts extends ListActivity{

    private static final String HASHMAP_ID = "_id";
    private CustomAdapter adap;

    static final String URL = "http://www.undignified.podbean.com/feed";

    //XML Node Keys
    static final String KEY_ITEM  = "item";
    static final String KEY_TITLE = "title";
    static final String KEY_DESCRIPTION = "itunes:subtitle";
    static final String KEY_PODCASTURL = "enclosure";

    public static final  ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();

    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 

        setContentView(R.layout.podcasts); 



        UndigParser uparser = new UndigParser();

        String xml = uparser.getXmlFromURL(URL);        

        Document doc = uparser.getDomElement(xml);    

        NodeList nl = doc.getElementsByTagName(KEY_ITEM);

        for(int i = 0; i < nl.getLength(); i++){

            HashMap<String, String> map = new HashMap<String, String>();
            Element e = (Element) nl.item(i);


            map.put(KEY_TITLE, uparser.getValue(e, KEY_TITLE));
            map.put(KEY_DESCRIPTION, uparser.getValue(e, KEY_DESCRIPTION));
            map.put(KEY_PODCASTURL, uparser.getValue(e, KEY_PODCASTURL));



            menuItems.add(map);
        }

        adap = new CustomAdapter(Podcasts.this, menuItems);           
       ListView lv = (ListView) findViewById(R.id.LinearLayout01);

       lv.setAdapter(adap);


    }

    public static class CustomAdapter extends BaseAdapter implements Filterable{

        private LayoutInflater mInflater;
        private Context context;


        public CustomAdapter(Context context, ArrayList<HashMap<String,String>>menuItems){

            mInflater = LayoutInflater.from(context);
            this.context = context;
        }

        public View getView(final int position, View convertView, ViewGroup parent){
            ViewHolder holder;

                convertView = mInflater.inflate(R.layout.list_item, null);

                holder = new ViewHolder();
                holder.description=(TextView)convertView.findViewById(R.id.description);
                holder.podcasturl=(TextView)convertView.findViewById(R.id.podcasturl);
                holder.title=(TextView)convertView.findViewById(R.id.title);
                holder.downloadBTN=(Button)convertView.findViewById(R.id.btnStartDownload);

                convertView.setOnClickListener(new OnClickListener(){
                    private int pos = position;

                    @Override
                    public void onClick(View v){
                        Toast.makeText(context, "Text-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();
                    }
                });

                holder.downloadBTN.setOnClickListener(new OnClickListener(){
                    private int pos = position;

                    @Override
                    public void onClick(View v){
                        Toast.makeText(context, "Button-"+String.valueOf(pos), Toast.LENGTH_SHORT).show();
                    }
                });
                convertView.setTag(holder);
            return convertView;
        }

        static class ViewHolder{
            TextView description;
            TextView title;
            TextView podcasturl;
            Button downloadBTN;
        }

        @Override
        public int getCount() {

            Log.d("Sizetest2343",""+menuItems.size());
            return menuItems.size();
        }

        @Override
        public Object getItem(int position) {

            return null;
        }

        @Override
        public long getItemId(int position) {

            return position;
        }

        @Override
        public Filter getFilter() {
            return null;
        }
    }

 }

The list_item.xml

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

<LinearLayout
    android:id="@+id/LinearLayout01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <Button
        android:id="@+id/startPodcastDownload"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:focusable="false"
        android:text="Download Podcast"> 
    </Button>        


</LinearLayout>    
        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/LinearLayout01"
            android:textColor="#acacac"
            android:paddingBottom="2dip">
        </TextView>
        <TextView
            android:id="@+id/description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/LinearLayout01"
            android:layout_below="@id/title"
            android:textColor="#acacac"
            android:paddingBottom="2dip">
        </TextView>
        <TextView
            android:id="@+id/podcasturl"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/LinearLayout01"
            android:layout_below="@+id/description"
            android:textColor="#acacac"
            android:paddingBottom="2dip">
        </TextView>

</RelativeLayout>
  • 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-08T15:20:44+00:00Added an answer on June 8, 2026 at 3:20 pm

    I think part of the problem could be your line of code:

    ListView lv = (ListView) findViewById(R.id.LinearLayout01);
    

    Here, you are trying to make a ListView from a LinearLayout.
    I would usually have something like this in my layout:

    <ListView android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="0.7" />
    

    Then you inflate the listview in your activity, like so:

    ListView friendList = (ListView)findViewById(android.R.id.list);
    

    Its important to use the android.R.id.list parameter.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.