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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:29:41+00:00 2026-06-04T07:29:41+00:00

I am getting this weird error, it seems like every time I edit the

  • 0

I am getting this weird error, it seems like every time I edit the position of the child views in my RelativeLayout by code I get a runtime error like FATAL EXCEPTION: MAIN, and a ClassCastException: ChildView’s class.

At first it was my ImageView, so I tried moving it using the GUI in Eclipse, then it was my LinearLayout so I did the same, but then it juggles back to the ImageView, and so on.. I wonder what’s wrong with my Layout? Here’s my main.xml coding:

<TextView
    android:id="@+id/txtVersion"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:padding="10dp"
    android:text="version 1.0"
    android:textColor="#000000"
    android:textSize="15sp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/txtLogo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:background="@drawable/logo_background"
    android:gravity="center"
    android:padding="20dp"
    android:paddingBottom="5dp"
    android:paddingRight="20dp"
    android:paddingTop="5dp"
    android:text="Ngaji Yuk"
    android:textColor="#FFFFFF"
    android:textSize="25sp"
    android:textStyle="bold" />

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:gravity="center"
    android:orientation="vertical"
    android:paddingBottom="5dp"
    android:paddingRight="20dp"
    android:paddingTop="5dp" >

    <Button
        android:id="@+id/btnRead"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:gravity="center"
        android:padding="20dp"
        android:paddingBottom="5dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="5dp"
        android:text="Mulai Ngaji"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <Button
        android:id="@+id/btnIndex"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:gravity="center"
        android:padding="20dp"
        android:paddingBottom="5dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="5dp"
        android:text="Indeks"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

    <Button
        android:id="@+id/btnAbout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:gravity="center"
        android:padding="20dp"
        android:paddingBottom="5dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="5dp"
        android:text="Tentang Aplikasi"
        android:textColor="#FFFFFF"
        android:textSize="20sp"
        android:textStyle="bold" />

</LinearLayout>

<ImageView
    android:id="@+id/imgMamat"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:src="@drawable/ic_launcher" />

There is no coding in my MainActivity except assigning variable and that’s only to the Buttons inside the LinearLayout.

Oh and do excuse me if it’s a silly question, I’m a total beginner in Android, thank you.

edit: Here’s my Logcat:

05-18 11:17:08.920: E/AndroidRuntime(516): FATAL EXCEPTION: main 05-18
11:17:08.920: E/AndroidRuntime(516): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{com.rangga.elearning.ngaji/com.rangga.elearning.ngaji.MainActivity}:
java.lang.ClassCastException: android.widget.LinearLayout 05-18
11:17:08.920: E/AndroidRuntime(516): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-18 11:17:08.920: E/AndroidRuntime(516): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-18 11:17:08.920: E/AndroidRuntime(516): at
android.app.ActivityThread.access$2300(ActivityThread.java:125) 05-18
11:17:08.920: E/AndroidRuntime(516): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-18 11:17:08.920: E/AndroidRuntime(516): at
android.os.Handler.dispatchMessage(Handler.java:99) 05-18
11:17:08.920: E/AndroidRuntime(516): at
android.os.Looper.loop(Looper.java:123) 05-18 11:17:08.920:
E/AndroidRuntime(516): at
android.app.ActivityThread.main(ActivityThread.java:4627) 05-18
11:17:08.920: E/AndroidRuntime(516): at
java.lang.reflect.Method.invokeNative(Native Method) 05-18
11:17:08.920: E/AndroidRuntime(516): at
java.lang.reflect.Method.invoke(Method.java:521) 05-18 11:17:08.920:
E/AndroidRuntime(516): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-18 11:17:08.920: E/AndroidRuntime(516): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-18
11:17:08.920: E/AndroidRuntime(516): at
dalvik.system.NativeStart.main(Native Method) 05-18 11:17:08.920:
E/AndroidRuntime(516): Caused by: java.lang.ClassCastException:
android.widget.LinearLayout 05-18 11:17:08.920: E/AndroidRuntime(516):
at
com.rangga.elearning.ngaji.MainActivity.onCreate(MainActivity.java:35)
05-18 11:17:08.920: E/AndroidRuntime(516): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-18 11:17:08.920: E/AndroidRuntime(516): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-18 11:17:08.920: E/AndroidRuntime(516): … 11 more

Cleaning the project seems to fixed it. It’s kinda annoying when problems like this show up, even though all the codes shows no 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-04T07:29:42+00:00Added an answer on June 4, 2026 at 7:29 am

    try clean and build, it may be due to some previous refences of the xml views remain

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

Sidebar

Related Questions

I keep getting this weird error message every time I'm testing my app on
I am getting this weird error while running cucumber test: ERROR Mongo::OperationFailure: Database command
I am getting this weird RunTime error. The classes compile easy on eclipse but
For almost a week i'm getting this weird error when i'm trying to run
My first time using sharedPreferences and i can't seem to get past this error.
After uninstalling ActiveState I've been getting this weird error when trying to execute perl
I am getting this weird error when making a WP7 app, and I can
I am getting this weird error with _snprintf_s: int ival = strlen(F(LL)L); char buff[32];
Okay this is werid, i keep getting the error, randomly. ValueError: matrix must be
I'm getting a weird return when executing this query : SELECT * FROM rrp

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.