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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:45:13+00:00 2026-05-29T09:45:13+00:00

I am building this app and I can’t make it work. Here is the

  • 0

I am building this app and I can’t make it work. Here is the code and if you find the problem please post the solution.

This is the Main Activity

package in.isuru.caf;

//imports imported here. removed to simplify the code.

public class MainList extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final String[] main_items_array = getResources().getStringArray(R.array.main_items);
    setListAdapter(new ArrayAdapter<String>(MainList.this, android.R.layout.simple_list_item_1, main_items_array));

    final ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
          // When clicked, show a toast with the TextView text
          String selectedFromList = (String) (lv.getItemAtPosition(position));
          Toast.makeText(getApplicationContext(), selectedFromList, Toast.LENGTH_SHORT).show();

          if(selectedFromList.contains("Top 20 Questions")){
                Intent mainIntent = new Intent(MainList.this, in.isuru.caf.Top20Questions.class);
                startActivity(mainIntent);
          }

        }
      });

  }
}

This is the second activity.

package in.isuru.caf;

import in.isuru.caf.R;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class Top20Questions extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    WebView myWebView = (WebView) findViewById(R.id.webview);
    myWebView.loadUrl("http://www.forums.catholic.com/forumdisplay.php?f=4&daysprune=-1&order=desc&sort=views");

    setContentView(R.layout.top_20_questions);
}

}

This is the AndroidManifest.xml file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.isuru.caf"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".MainList" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Top20Questions"></activity>


</application>

</manifest>

And I am getting this error.

01-21 12:18:44.231: E/AndroidRuntime(1767): 
java.lang.RuntimeException: Unable to start activity
ComponentInfo{in.isuru.caf/in.isuru.caf.Top20Questions}: 
java.lang.NullPointerException
  • 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-29T09:45:14+00:00Added an answer on May 29, 2026 at 9:45 am

    You must call the setContentView() method before trying to access any resources.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.top_20_questions);
    
        WebView myWebView = (WebView) findViewById(R.id.webview);
        ...
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building application with GWT + GAE on my MAC. In this app i
When building a new iPhone app in Xcode, I'm getting this error: codesign error:
I am building a Facebook App which is heavy on Javascript. For this I
When building code like this: <script type=text/javascript src=<%=ResolveUrl(~/js/js.js)%>></script> or <input type=image src=<%=ResolveUrl(~/img/submit.png)%> /> Should
I am building one app & this is the setting page(Activity view) of my
This problem has been KILLING me. I've been working on this app for 8
The quick overview is this: for my web app I can write most of
While building this web service and the app that calls it, we have noticed
I am building a completely ajax web app (this is the first web app
I am building a rails 3 App. I'll try to describe this application to

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.