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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:28:01+00:00 2026-06-11T00:28:01+00:00

I currently develop an application which contains a custom ListView . I developed a

  • 0

I currently develop an application which contains a custom ListView. I developed a custom array adapter.
I think my app crashes here:

ListView DirectoryView = (ListView) findViewById(R.id.fileListView);

So i think the error is in the activity_main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ListView
    android:id="@+id/fileListView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1" >
</ListView>

Here is my LogCat:

09-09 11:19:21.254: E/Trace(1152): error opening trace file: No such file or directory (2)
09-09 11:19:21.484: D/AndroidRuntime(1152): Shutting down VM
09-09 11:19:21.484: W/dalvikvm(1152): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
09-09 11:19:21.504: E/AndroidRuntime(1152): FATAL EXCEPTION: main
09-09 11:19:21.504: E/AndroidRuntime(1152): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.teamdroid.explorer/com.teamdroid.explorer.MainActivity}: java.lang.NullPointerException
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.os.Looper.loop(Looper.java:137)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.ActivityThread.main(ActivityThread.java:4745)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at java.lang.reflect.Method.invokeNative(Native Method)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at java.lang.reflect.Method.invoke(Method.java:511)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at dalvik.system.NativeStart.main(Native Method)
09-09 11:19:21.504: E/AndroidRuntime(1152): Caused by: java.lang.NullPointerException
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.Activity.findViewById(Activity.java:1825)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at com.teamdroid.explorer.listDirectory.getDirectory(listDirectory.java:20)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at com.teamdroid.explorer.MainActivity.onCreate(MainActivity.java:33)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.Activity.performCreate(Activity.java:5008)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
09-09 11:19:21.504: E/AndroidRuntime(1152):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-09 11:19:21.504: E/AndroidRuntime(1152):     ... 11 more

Please can you help me. I am searching this error for 2 day.
thanks!

EDIT:
I have a third file which lists a directory in this listview:

    public class listDirectory extends ListActivity {

    String[] DirList;

    public void onCreate(Bundle icicle) {
        setContentView(R.layout.activity_main);
        super.onCreate(icicle);
    }   

    public void getDirectory (){
        MainActivity main = new MainActivity();
        String path = main.getPath();

        ListView DirectoryView = (ListView) findViewById(R.id.fileListView);
        CustomArrayAdapter adapter = new CustomArrayAdapter(getApplicationContext(), DirList);

        File file = new File(path);
        File[] FileList = file.listFiles();

        java.util.Arrays.sort(FileList);

        for(int i = 0; i < FileList.length; i++){
            if(FileList[i].isDirectory()){
                DirList[i] = (FileList[i].getName() + " [folder]");
            } else{
                DirList[i] = (FileList[i].getName() + " [file]");
            }
         }

         DirectoryView.setAdapter(adapter);
    }
}

I think in this file is the error.

  • 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-11T00:28:02+00:00Added an answer on June 11, 2026 at 12:28 am

    I think that you did not set content view inside onCreate() method and therefor findViewById is unable to find view objects and so returns null.

    Assume that your XML layout file is my_layout.xml. Inside onCreate(…) add this line:

    setContentView(R.layout.my_layout);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

currently I develop a C#.Net application in which I'm using a custom control I
Here's my problem. I'm currently trying to develop a .Net Compact Framework 2.0 application
I'm currently trying to develop an android application in eclipse(java) which shows some jokes
I currently develop a server application which has to receive serialized data from clients,
I currently develop an application hosted at google app engine. However, gae has many
I am currently trying to develop an application which uses Skype API to call
Thanks for reading! I am currently trying to develop an application which will backup
I am currently trying to develop a PHP application in which my server downloads
I currently develop an application which is written in C++. For scripting purposes I
I currently have an application, which is just a standard android app, but I

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.