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

  • Home
  • SEARCH
  • 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 8481113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:28:36+00:00 2026-06-10T19:28:36+00:00

I have a small problem while navigating the screen, actually I make an event

  • 0

I have a small problem while navigating the screen, actually I make an event from a menu button to show the content of a file from a SD card. Whenever the menu is clicked the run time exception occurs I have attached my codes,error logs and xml herewith. Any help will be highly appreciated.

menu button handling
//Handling the Menu button

public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {

             startActivity(new Intent(ContactListActivity1.this,App2Activity.class)); 
             finish();


        }

    return true;
}

App2Activity.java

public class App2Activity extends ContactListActivity1 {


    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.file_view);


            File sdcard= Environment.getExternalStorageDirectory();
            File dir = new File(sdcard.getAbsolutePath() + "/dir1/dir2");

            File file = new File(dir, "my_group.txt");

            StringBuilder text = new StringBuilder();
            try {
                BufferedReader br = new BufferedReader(new FileReader(file));
                String line;

                while ((line = br.readLine()) != null) {
                    text.append(line);
                    text.append('\n');

                }
            }
            catch (IOException e) {

                e.printStackTrace();


            }


            TextView tv = (TextView)findViewById(R.id.text_view);                   
            tv.setText(text);

    }

}

file_view.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
>
<TextView 

    android:id="@+id/text_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    />




</LinearLayout>

Error log

09-04 13:51:33.680: W/CursorWrapperInner(25536): Cursor finalized without prior close()
09-04 13:51:33.880: I/System.out(25536): Am I Coming here  !! 
09-04 13:51:33.900: D/AndroidRuntime(25536): Shutting down VM
09-04 13:51:33.900: W/dalvikvm(25536): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
09-04 13:51:33.940: E/AndroidRuntime(25536): FATAL EXCEPTION: main
09-04 13:51:33.940: E/AndroidRuntime(25536): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.contactlistactivity1/com.example.contactlistactivity1.App2Activity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.ActivityThread.access$600(ActivityThread.java:122)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.os.Looper.loop(Looper.java:137)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.ActivityThread.main(ActivityThread.java:4340)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at java.lang.reflect.Method.invokeNative(Native Method)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at java.lang.reflect.Method.invoke(Method.java:511)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at dalvik.system.NativeStart.main(Native Method)
09-04 13:51:33.940: E/AndroidRuntime(25536): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.ListActivity.onContentChanged(ListActivity.java:243)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.Activity.setContentView(Activity.java:1835)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at com.example.contactlistactivity1.App2Activity.onCreate(App2Activity.java:20)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.Activity.performCreate(Activity.java:4465)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-04 13:51:33.940: E/AndroidRuntime(25536):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-04 13:51:33.940: E/AndroidRuntime(25536):    ... 11 more
  • 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-10T19:28:37+00:00Added an answer on June 10, 2026 at 7:28 pm

    You are using a ListActivity . So ListActivity expects your content View to have a listView with id @android:id/list

    So change your xml to below

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
    >
    <TextView 
    
        android:id="@+id/text_view" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        />
    <ListView android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#00FF00"
        android:layout_weight="1"
        android:drawSelectorOnTop="false"/>    
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have actually a small problem with file i/o and finding the right algorithm
While doing some small regex task I came upon this problem. I have a
I have a small problem while working on software for a Surface: I have
I have a small but weird problem while encoding php arrays to json. I
I have been struggling with a small problem for a while. It's been there
I have a small problem in java while using generics. I have a class
I have a small problem while developing an application. I want to access all
I have small problem with JavaMail. Sometimes method getRecipients from class Message returns weird
I have a small problem with exporting MySQL data to CSV file, it print
have small problem, and would very much appreciate help :) I should convert byte

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.