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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:30:44+00:00 2026-06-02T07:30:44+00:00

My android application works fine without these two lines: layMain= (LinearLayout) findViewById(R.id.layout_main); layMain.setOnTouchListener((OnTouchListener) this);

  • 0

My android application works fine without these two lines:

    layMain=  (LinearLayout) findViewById(R.id.layout_main);
    layMain.setOnTouchListener((OnTouchListener) this); 

The debugging showed me that the system is forced to close after the first line of those.
What’s the reason? Thank you.

Here’s my onCreate() Method,

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set main.XML as the layout for this Activity
    setContentView(R.layout.main);


    // Add these two lines
    layMain=  (LinearLayout) findViewById(R.id.layout_main);
    layMain.setOnTouchListener((OnTouchListener) this); 


    // Add a few countries to the spinner
    Spinner spinnerCountries = (Spinner) findViewById(R.id.spinner_country);
    @SuppressWarnings({ "unchecked", "rawtypes" })
    ArrayAdapter countryArrayAdapter = new ArrayAdapter(this,
                android.R.layout.simple_spinner_dropdown_item,
                new String[] { "Canada", "USA" });
    spinnerCountries.setAdapter(countryArrayAdapter);

}

Stack trace:

04-19 19:31:12.146: DEBUG/AndroidRuntime(484): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
04-19 19:31:12.146: DEBUG/AndroidRuntime(484): CheckJNI is ON
04-19 19:31:13.834: DEBUG/AndroidRuntime(484): Calling main entry com.android.commands.pm.Pm
04-19 19:31:13.934: DEBUG/AndroidRuntime(484): Shutting down VM
04-19 19:31:13.954: INFO/AndroidRuntime(484): NOTE: attach of thread 'Binder Thread #3' failed
04-19 19:31:13.967: DEBUG/dalvikvm(484): GC_CONCURRENT freed 101K, 71% free 297K/1024K, external 0K/0K, paused 2ms+2ms
04-19 19:31:13.967: DEBUG/jdwp(484): Got wake-up signal, bailing out of select
04-19 19:31:13.974: DEBUG/dalvikvm(484): Debugger has detached; object registry had 1 entries
04-19 19:31:15.246: DEBUG/AndroidRuntime(495): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
04-19 19:31:15.246: DEBUG/AndroidRuntime(495): CheckJNI is ON
04-19 19:31:16.904: DEBUG/AndroidRuntime(495): Calling main entry com.android.commands.am.Am
04-19 19:31:16.984: INFO/ActivityManager(74): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=zaid.project.SlidingActivity/.SlidingActivityActivity } from pid 495
04-19 19:31:17.074: DEBUG/AndroidRuntime(495): Shutting down VM
04-19 19:31:17.124: INFO/AndroidRuntime(495): NOTE: attach of thread 'Binder Thread #3' failed
04-19 19:31:17.236: DEBUG/dalvikvm(495): GC_CONCURRENT freed 102K, 69% free 318K/1024K, external 0K/0K, paused 2ms+4ms
04-19 19:31:17.274: DEBUG/jdwp(495): Got wake-up signal, bailing out of select
04-19 19:31:17.274: DEBUG/dalvikvm(495): Debugger has detached; object registry had 1 entries
04-19 19:31:17.564: INFO/ActivityManager(74): Start proc zaid.project.SlidingActivity for activity zaid.project.SlidingActivity/.SlidingActivityActivity: pid=505 uid=10034 gids={}
04-19 19:31:19.584: DEBUG/AndroidRuntime(505): Shutting down VM
04-19 19:31:19.584: WARN/dalvikvm(505): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-19 19:31:19.634: ERROR/AndroidRuntime(505): FATAL EXCEPTION: main
04-19 19:31:19.634: ERROR/AndroidRuntime(505): java.lang.RuntimeException: Unable to start activity ComponentInfo{zaid.project.SlidingActivity/zaid.project.SlidingActivity.SlidingActivityActivity}: java.lang.ClassCastException: android.widget.ViewFlipper
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.os.Looper.loop(Looper.java:123)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at java.lang.reflect.Method.invokeNative(Native Method)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at java.lang.reflect.Method.invoke(Method.java:507)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at dalvik.system.NativeStart.main(Native Method)
04-19 19:31:19.634: ERROR/AndroidRuntime(505): Caused by: java.lang.ClassCastException: android.widget.ViewFlipper
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at zaid.project.SlidingActivity.SlidingActivityActivity.onCreate(SlidingActivityActivity.java:28)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-19 19:31:19.634: ERROR/AndroidRuntime(505):     ... 11 more
04-19 19:31:19.664: WARN/ActivityManager(74):   Force finishing activity zaid.project.SlidingActivity/.SlidingActivityActivity
04-19 19:31:20.344: WARN/ActivityManager(74): Activity pause timeout for HistoryRecord{405f6c20 zaid.project.SlidingActivity/.SlidingActivityActivity}
04-19 19:31:31.898: WARN/ActivityManager(74): Activity destroy timeout for HistoryRecord{405f6c20 zaid.project.SlidingActivity/.SlidingActivityActivity}
04-19 19:32:12.944: INFO/Process(505): Sending signal. PID: 505 SIG: 9
04-19 19:32:12.985: INFO/ActivityManager(74): Process zaid.project.SlidingActivity (pid 505) has died.
04-19 19:32:13.676: WARN/InputManagerService(74): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@406e5518
  • 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-02T07:30:45+00:00Added an answer on June 2, 2026 at 7:30 am

    I suspect the problem is in this line:

    layMain = (LinearLayout) findViewById(R.id.layout_main);
    

    (Is this line 28 in SlidingActivityActivity.java?)

    You didn’t post your XML file, so I’m just guessing here. Most likely, R.id.layout_main points to a ViewFlipper containing your LinearLayout. Check your XML to make sure you are using correct ID’s.

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

Sidebar

Related Questions

This sql command works fine in sqlitemanager but in my android application this don't
I write an Android Application and I use a ListView and it works fine,
I have implemented Pull to refresh functionality in my android application, its works fine.
I have implemented Twitter4J in my Android application and it's works fine. But after
My application works very fine on emulator without any logcat error, but it abruptly
When I execute my android application it works fine, except the view will not
I have created an android application using (Jquery & PhoneGap). The application works fine
I am developing an Android application which always listen voice from user. It works
My app works fine when it's unsigned (debugging, etc..), also when exporting without ProGuard.
I have this android application which uses java-javascript bridge to pick up information from

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.