title: Application Crashing - Null Pointer Exception [Android]
body: <p>I'm developing an RSS Reader at the moment and it seems to be crashing and I can't seem to figure out how to fix it. Previously, when clicking on an item(article) in the ListView, it would open the article url in a Web View. It didn't crash when I would attempt to open the webview of the article.
  However, after making the following changes, it is crashing when I click on an item(article) in the ListView.</p>
  
  <ol>
  <li>I have removed the Web View class and layout file</li>
  <li>I have replaced the layout file with a normal Relative Layout and
  set the content view of the new Activity created, that I called
  'ArticleActivity'</li>
  </ol>
  
  <p>I intend on using the data parsed from an article and be able to display that on a Table Layout or Relative Layout View.</p>
  
  <p><strong>ListRSSItemsActivity:</strong></p>
  
  <pre><code>public class ListRSSItemsActivity extends ListActivity {
  
      // Progress Dialog
      private ProgressDialog pDialog;
  
      // Array list for list view
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; rssItemList = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;();
  
      RSSParser rssParser = new RSSParser();
  
      List&lt;RSSItem&gt; rssItems = new ArrayList&lt;RSSItem&gt;();
  
      RSSFeed rssFeed;
  
      private static String TAG_TITLE = "title";
      private static String TAG_LINK = "link";
      private static String TAG_DESCRIPTION = "description";
      private static String TAG_PUBDATE = "pub_date";
      private static String TAG_GUID = "guid"; // not used
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.rss_item_list);
  
          // get intent data
          Intent i = getIntent();
  
          // SQLite Row id
          Integer site_id = Integer.parseInt(i.getStringExtra("id"));
  
          // Getting Single website from SQLite
          RSSDatabaseHandler rssDB = new RSSDatabaseHandler(getApplicationContext());
  
  
          WebSite site = rssDB.getSite(site_id);
          String rss_link = site.getRSSLink();
  
          /**
           * Calling a backgroung thread will loads recent articles of a website
           * @param rss url of website
           * */
          new loadRSSFeedItems().execute(rss_link);
  
          // selecting single ListView item
          ListView lv = getListView();
  
          // Launching new screen on Selecting Single ListItem
          lv.setOnItemClickListener(new OnItemClickListener() {
  
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
  
                  // getting listview
                  View v = (View)view.getParent(); 
                  TextView tv = (TextView)v.findViewById(R.id.title);
                  String title = tv.getText().toString();
                  String description = ((TextView) view.findViewById(R.id.link)).getText().toString();
  
                  // Starting new intent
                  Intent in = new Intent(getApplicationContext(), ArticleActivity.class);
                  in.putExtra(TAG_TITLE, title);
                  in.putExtra(TAG_DESCRIPTION, description);
                  startActivity(in);
              }
          });
      }
  
      /**
       * Background Async Task to get RSS Feed Items data from URL
       * */
      class loadRSSFeedItems extends AsyncTask&lt;String, String, String&gt; {
  
          /**
           * Before starting background thread Show Progress Dialog
           * */
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(
                      ListRSSItemsActivity.this);
              pDialog.setMessage("Loading recent articles...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(false);
              pDialog.show();
          }
  
          /**
           * getting all recent articles and showing them in listview
           * */
          @Override
          protected String doInBackground(String... args) {
              // rss link url
              String rss_url = args[0];
  
              // list of rss items
              rssItems = rssParser.getRSSFeedItems(rss_url);
  
              // looping through each item
              for(RSSItem item : rssItems){
                  // creating new HashMap
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                  // adding each child node to HashMap key =&gt; value
                  map.put(TAG_TITLE, item.getTitle());
                  map.put(TAG_LINK, item.getLink());
                  map.put(TAG_PUBDATE, item.getPubDate());
  
  
                  // adding HashList to ArrayList
                  rssItemList.add(map);
              }
  
              // updating UI from Background Thread
              runOnUiThread(new Runnable() {
                  public void run() {
                      /**
                       * Updating parsed items into listview
                       * */
                      ListAdapter adapter = new SimpleAdapter(
                              ListRSSItemsActivity.this,
                              rssItemList, R.layout.rss_item_list_row,
                              new String[] { TAG_LINK, TAG_TITLE, TAG_PUBDATE, TAG_DESCRIPTION },
                              new int[] { R.id.page_url, R.id.title, R.id.pub_date, R.id.link });
  
                      // updating listview
                      setListAdapter(adapter);
                  }
              });
              return null;
          }
  
          /**
           * After completing background task Dismiss the progress dialog
           * **/
          protected void onPostExecute(String args) {
              // dismiss the dialog after getting all products
              pDialog.dismiss();
          }
      }
  }
  </code></pre>
  
  <p><strong>rss_item_list_row.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical" 
      android:padding="8dip"&gt;
  
      &lt;TextView android:id="@+id/page_url"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:visibility="gone"/&gt;
  
      &lt;!-- Article title --&gt;
      &lt;TextView
          android:id="@+id/title"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:paddingBottom="1dip"
          android:textSize="18sp"
          android:textStyle="bold"
          android:textColor="#303030" /&gt;
  
      &lt;!-- published date --&gt;
      &lt;TextView
          android:id="@+id/pub_date"
          android:layout_below="@id/title"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingBottom="3dip"
          android:textSize="14sp"
          android:textColor="#b70400"/&gt;
  
      &lt;!-- article description --&gt;
      &lt;TextView android:id="@+id/link"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:paddingBottom="6dip"
          android:textSize="15sp"
          android:textColor="#8d8d8d"
          android:layout_below="@id/pub_date"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Stacktrace:</strong></p>
  
  <pre><code>    USER_COMMENT=null
  ANDROID_VERSION=4.1.2
  APP_VERSION_NAME=1.0
  BRAND=samsung
  PHONE_MODEL=GT-N8000
  CUSTOM_DATA=
  STACK_TRACE=java.lang.NullPointerException
  at com.j.infographx.ListRSSItemsActivity$1.onItemClick(ListRSSItemsActivity.java:74)
  at android.widget.AdapterView.performItemClick(AdapterView.java:301)
  at android.widget.AbsListView.performItemClick(AbsListView.java:1287)
  at android.widget.AbsListView$PerformClick.run(AbsListView.java:3078)
  at android.widget.AbsListView$1.run(AbsListView.java:4161)
  at android.os.Handler.handleCallback(Handler.java:615)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4921)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>As far as I can tell, there seems to be a problem on line 74 in my ListRSSItemsActivity Class, i.e.,</p>
  
  <pre><code>String title = ((TextView) view.findViewById(R.id.view_title)).getText().toString();
  </code></pre>
  
  <p>I don't know how to fix it though. Can someone please help?</p>