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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:03:51+00:00 2026-06-08T07:03:51+00:00

Explanation at the end of the code Java: void GetNextQuestion() { QuestNum++; /// ERROR

  • 0

Explanation at the end of the code

Java:

void GetNextQuestion()
{
    QuestNum++;
    /// ERROR ON VERY NEXT LINE
    ProgressBar pbar = (ProgressBar)this.findViewById(R.id.progressBar2);
    TextView tvSection = (TextView)this.findViewById(R.id.section);
    TextView tvSubsection = (TextView)this.findViewById(R.id.subsection);
    TextView tvQuest = (TextView)this.findViewById(R.id.quest);
    if(QuestNum > 0 && QuestNum < 180)
    {
        tvSection.setText(R.string.s1);
        tvSubsection.setText(R.string.ss1);
        spin.setSecondaryProgress((int)((QuestNum/180) * 1000));
    }
    if(QuestNum > 179 && QuestNum < 285)
    {
        tvSection.setText(R.string.s2);
        tvSubsection.setText(R.string.ss2);         
    }
}

XML:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">

 <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp" 
    android:layout_weight="1">



<ImageView
    android:id="@+id/icon"
    android:layout_width="57dp"
    android:layout_height="54dp"
    android:src="@drawable/devil" />


<TextView
    android:id="@+id/section"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/icon"
    android:text="@string/nunca"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" 
    android:visibility="invisible" />


<TextView
    android:id="@+id/subsection"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/section"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/icon"
    android:text="@string/nunca"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<ImageView
    android:id="@+id/help"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/helpico" />

<ImageView
    android:id="@+id/exit"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/subsection"
    android:layout_alignParentRight="true"
    android:src="@drawable/exitico" />

<TextView
    android:id="@+id/haveyou"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/subsection"
    android:layout_marginTop="18dp"
    android:text="@string/nunca"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/quest"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:text="@string/load"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<Button
    android:id="@+id/butyes"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_above="@+id/progressBar2"
    android:layout_marginBottom="30dp"
    android:text="Yes" />

    <Button
    android:id="@+id/butno"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_above="@+id/progressBar2"
    android:layout_marginBottom="30dp"
    android:text="No" />

    <ProgressBar
        android:id="@+id/progressBar2"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:max="1000"
        android:progress="0"/>

</RelativeLayout>
<com.google.ads.AdView
   android:id="@+id/adView"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   app:adSize="BANNER"
   app:adUnitId="a14ffb06b21e68e"
   app:loadAdOnCreate="true" >
</com.google.ads.AdView>
</LinearLayout>

Error:

E/AndroidRuntime(20649): FATAL EXCEPTION: main
E/AndroidRuntime(20649): java.lang.ClassCastException: android.widget.Button
at com.ndai.ptest.a1000test.GetNextQuestion(a1000test.java:146)
at com.ndai.ptest.a1000test$QuestAnsTask.onPostExecute(a1000test.java:3319)
at com.ndai.ptest.a1000test$QuestAnsTask.onPostExecute(a1000test.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:417)
at android.os.AsyncTask.access$300(AsyncTask.java:127)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

here is what i don’t understand…it is giving me a casting error…i am casting a progressbar tp a progressbar…am i just missing a typo or something…i just need an extra set of eyes on this one

EDIT:

I did however not receive this error until after i rearranged stuff on the xml

  • 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-08T07:03:53+00:00Added an answer on June 8, 2026 at 7:03 am

    I FIXED IT

    I was reading how other people have been having the same issues when not using the GUI to change the layout…so i followed these steps

    1. Fix the project (right click project, got android tools then the only option that says fix)
    2. Delete R.java
    3. Fix The Project again
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Look at the following line of java: Mac.getInstance(HmacSHA1); If I put this in a
Versioned URL's are mentioned near the bottom of this section with very little explanation:
I've done a small mistake while coding this week-end. In the following code, I'm
I'm learning about deadlocks in Java, and there's this sample code from Sun's official
See important new discoveries 1 and 2 at end of this explanation. I am
I need some explanation for this code. This is the example code given by
I think just showing my whole code is better than my explanation.. actually I'm
While compiling the following code {\centering {\includegraphics[scale=.5]{splash.eps}} \caption{Splash Screen} \par} \end{figure} Splash screen is
I end up writing a lot of code that looks like var ordered =
The following code gives segmentation error when compiled with pgf90 on the Linux system,

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.