Rss reader with custom array adapter

I'm making an android app with a rss feed in android studio and so I'm trying to put the title and description from:, to two textviews using a custom adapter. The rss feed is in a tab. And each time I try to run my program I get an exception and the problem occurs in this class:

public class LAdapter extends ArrayAdapter<Info> { public LAdapter(Context context, ArrayList<Info> nfos) {super(context, 0,nfos);} @Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position Info info = getItem(position); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.basic_list_item, parent, false); } // Lookup view for data population TextView title = (TextView) convertView.findViewById(; TextView description = (TextView) convertView.findViewById(; title.setText(info.Title); description.setText(info.Description); // Return the completed view to render on screen return convertView; } }

Partial Tab_1.class:

public class Tab_1 extends Fragment { ListView mList; ArrayList<Info> arrayOfInfo; LAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.tab_1, container, false); LAdapter adapter = new LAdapter(getActivity(), arrayOfInfo); #Line 44-> mList = (ListView) v.findViewById(; new GetRssFeed().execute(""); mList.setAdapter(adapter); return v; }


Process: com.example.pauly.myapplication, PID: 3896 java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference at android.widget.ArrayAdapter.getCount( at android.widget.ListView.setAdapter( at com.example.pauly.myapplication.Tabs.Tab_1.onCreateView( at at at at at at at at at at ...


LAdapter adapter = new LAdapter(getActivity(), arrayOfInfo);

arrayOfInfo is null (it's not even initialized), because you call your asynctask after arrayOfInfo. With the data you receive from the DoInBackground method, you can set arrayOfInfo with data in the method OnPostExecute in asynctask and after this array is set with data, you can call in OnPostExecute also

LAdapter adapter = new LAdapter(getActivity(), arrayOfInfo);

OnPostExecute is basically handling your UI.

Category:android Time:2018-10-27 Views:1

Related post

  • Tabhost with two listviews with Custom array Adapter, both list showing same data 2011-05-19

    I have one activity in which I am having one TabHost with two tabs. Both the tabs have one listview each. The activity has one button which start an aync job to get data from internet and then the data is divided into two array adapters one for each

  • Passing value to other activity with custom array adapter 2018-09-01

    may I ask how to pass the value to other Activity using the code below? This is because I want to pass each value of TextView in my ListView to another Activity. Thank you. public class MySimpleArrayAdapter extends ArrayAdapter<String> { private fin

  • how to implement filter in listview with custom array adaptor? 2011-11-17

    I have went through other similar questions, but I'm unable to find a solution. I want to make my custom array adapter filterable, when user presses a key sequence. I'm new at it. Please let me know what should I add and where. public class ShowTags

  • Android ListView with Custom Array adaptor image reoccuring 2012-02-01

    i am trying to setVisible a play icon on click of listview item just like in music player. I am using a custom array adapter, all is working good but when i scroll up/down and select any item on the list the previous play icon dosent go away. But if

  • Connecting a PS/2 magnetic stripe card reader with a USB adapter. Windows does not recognize it as a HID keyboard. 2012-10-02

    I'm trying to connect a PS/2 magnetic stripe card reader with a USB adapter to my computer. When ever I swipe a card a USB Device Not Recognized dialog pops up from the notification area. It says "One of the USB devices attached to this computer has

  • from simple list adapter to custom array adapter 2014-09-26

    I have a class which retrives data from my database and displays it in a listview using simple adapter public class ViewExs extends ListActivity { // Progress Dialog private ProgressDialog pDialog; // Creating JSON Parser object JSONParser jParser =

  • Fragments with custom list adapter causing crash on inflate view 2012-01-23

    I am attempting to convert one of my apps to use Fragments to improve how the app looks and works on ICS / Honeycomb but I've come across a problem which although I've spent many hours Googleing and reading answers on here I can't seem to find a fix

  • Spinner with custom cursor adapter and "empty" selection 2012-04-25

    i have cursor which selects records from my CarProfile table and use custom adapter to show brand, model and the linenceplate in the spinner selection. my problem is that i want to have selection which says "ALL" for a first item, so if chosen i coul

  • how to create rss reader with php? 2009-08-25

    i am creating rss reader application with is basicly getting rss url's from user and with php i am creating an rss reader.But i have some problems how to get rss content with php i try to use pear extension but i had some problem with

  • Strange behaviour with custom cursor adapter android 2010-10-12

    i have been having this issue for some time now, and have not gotten an answer for it yet. i have this custom Cursor adapter which i use to populate a list view from an sqlite database. Now my issue is that i want to populate the listview based on ce

  • Build RSS Reader with HTML and PHP 2010-12-18

    Could someone point me to a guide or some information on building a simple online rss reader. I've only been able to find guides on making rss feeds for your own site. Thanks --------------Solutions------------- Should it read contents from only one

  • Filtering ListView with custom (object) adapter 2011-04-25

    I'm trying to implement filtering of a ListView which is uses a custom object adapter, but I can't find any useful samples. The included code is very simplified, so no- keep in mind I can't use an regular ArrayAdapter. I have a EditText above the Lis

  • Android custom Array adapter and database connection 2013-05-23

    I couldn't find any solid information regarding this so here it goes; I am using information from SQLite db in my array adapter to show/hide a view. Array list data comes from file system and depending on user's choice a view in the row displayed or

  • Is there an RSS reader with sound notifications? 2014-06-10

    I'm looking for an RSS reader app for Windows Phone 7 that can give a sound notification whenever a new artickel is received by the RSS reader. --------------Solutions------------- Hello Pascal.Langen How are you today? On Zune marketplace there are

  • wrong list items get deleted instead of choosen items with custom list adapter 2011-11-06

    I've created a custom ListView with checkboxes. I wanted to delete the selected items on "Delete" menu option selection. I am handling the onCheckedChanged event on CheckBox. Here I maintain an ArrayList to note down the selected elements position. N

  • Custom Array Adapter 2011-11-13

    I'm writing a news-app and I'm having some trouble with displaying a custom list. All I want is that list items have 2 TextViews in them: News-Title and News-Description These are contained in 2 static arrays: homeScreen.title[] and homeScreen.descri

  • Android pull-to-refresh with custom ListView adapter 2012-02-25

    Am trying to implement chrisbane's pull-to-refresh library for my ListView ( It seems simple enough but what Im having trouble with is the fact it seems to require it's own data set, seperate to wh

  • custom array adapter for android listview 2012-03-10

    What I'm essentially trying to do is to populate my ListView with colored TextViews. I figured I had to create a custom ArrayAdapter. The adapter will take an array of objects of my class ColorElement. Here is the code for the adapter public class Co

  • Problem with custom cursor adapter for list view in Android 2010-08-10

    I have an app that will query a database and attempt to output results in a list format. my first attempt was to use a simpleCursorAdapter, which worked fine for string outputs such as name and status, but would not display the time field from my cur

Copyright (C), All Rights Reserved.

processed in 0.749 (s). 13 q(s)