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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:53:44+00:00 2026-06-11T01:53:44+00:00

I have two activities. ScreenOne.java and ScreenTwo.java. ScreenOne extends BaseScreen ScreenTwo extends ListActivity I

  • 0

I have two activities. ScreenOne.java and ScreenTwo.java.

ScreenOne extends BaseScreen
ScreenTwo extends ListActivity

I want ScreenTwo to extend BaseScreen as the Back button event makes the app crash.

this.mainListView = getListView();

This is the only line that throws up an error if I change the extension.

The error is:

The method getListView() is undefined for the type ScreenTwo.

My Back button code:

 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
     Intent intent = new Intent(getBaseContext(), ScreenThree.class); 
     startActivity(intent); 
        }
        return true;
    }

I need one of the following workarounds:

  • Make ScreenTwo extend BaseScreen
  • An alternative to the “troublesome” line of code
  • Override the Back button to start a new activity.

LogCat Output:

09-07 11:30:13.419: E/AndroidRuntime(2845): FATAL EXCEPTION: main
09-07 11:30:13.419: E/AndroidRuntime(2845): java.lang.ClassCastException: com.example.Droid.Screens.ScreenTwo
09-07 11:30:13.419: E/AndroidRuntime(2845): at com.example.Droid.Services.ScreenService.getCurrentScreen(ScreenService.java:226)
09-07 11:30:13.419: E/AndroidRuntime(2845): at com.example.Droid.Screens.BaseScreen.processKeyDown(BaseScreen.java:310)
09-07 11:30:13.419: E/AndroidRuntime(2845): at com.example.Droid.Main.onKeyDown(Main.java:183)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.view.KeyEvent.dispatch(KeyEvent.java:1256)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.app.Activity.dispatchKeyEvent(Activity.java:2078)
09-07 11:30:13.419: E/AndroidRuntime(2845): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1709)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2628)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2603)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.view.ViewRoot.handleMessage(ViewRoot.java:1875)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.os.Handler.dispatchMessage(Handler.java:99)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.os.Looper.loop(Looper.java:123)
09-07 11:30:13.419: E/AndroidRuntime(2845): at android.app.ActivityThread.main(ActivityThread.java:3687)
09-07 11:30:13.419: E/AndroidRuntime(2845): at java.lang.reflect.Method.invokeNative(Native Method)
09-07 11:30:13.419: E/AndroidRuntime(2845): at java.lang.reflect.Method.invoke(Method.java:507)
09-07 11:30:13.419: E/AndroidRuntime(2845): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-07 11:30:13.419: E/AndroidRuntime(2845): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-07 11:30:13.419: E/AndroidRuntime(2845): at dalvik.system.NativeStart.main(Native Method)
  • 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-11T01:53:45+00:00Added an answer on June 11, 2026 at 1:53 am

    If you are using @android:id/list as an ID of ListView, use:

    ListView listView = (ListView) findViewByID(android.R.id.list);
    

    else use:

    ListView listView = (ListView) findViewByID(R.id.listView); // the id of your listView given in xml file.
    

    In this way you don’t have to extend the ListActivity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have two activities, NewTransferMyOwn.java and FromAccount.java When I go from NewTransferMyOwn.java to FromAccount.java,
I have two Activities A and B. I want to have the shrink Animation
I want to know that if I have two activities in a program then
I have two activities: one displays an image and a button, the other displays
I have two activities but I want to apply a condition on application start,
I have two Activities and I want to keep a reference of a second
I have two activities Main (with a button in it) & Second, and I
I have two activities my first class is: DfbActivity.java and my second class is:

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.