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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:39:39+00:00 2026-06-07T14:39:39+00:00

ive been trying to build my app in eclipses workbench, however i have stumbled

  • 0

ive been trying to build my app in eclipses workbench, however i have stumbled across an error message reading “cannot cast from view to checkbox”. I have tried different things to resolve the issue to no avail, was wondering if someone could please help me out

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.View;
import android.widget.Checkbox;
import android.widget.TextView;

@SuppressLint("ParserError")
public class MainActivity extends Activity {
TextView textView;
CheckBox pepBox, cheeseBox;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    pepBox = 
            (CheckBox) findViewById(R.id.checkBox1);
    cheeseBox =
            (CheckBox) findViewById(R.id.checkBox2);
    textView =
            (TextView) findViewById(R.id.textView2);
}

that is the coding i have used

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:padding="@dimen/padding_medium"
    android:text="@string/hello_world"
    tools:context=".MainActivity" />

<CheckBox
    android:id="@+id/checkBox1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="57dp"
    android:text="@string/pepperoni" />

<CheckBox
    android:id="@+id/checkBox2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/checkBox1"
    android:layout_marginTop="33dp"
    android:text="@string/extra_cheese" />

<Button
    android:id="@+id/button1"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/checkBox1"
    android:layout_below="@+id/textView1"
    android:onClick="onButton1Click"
    android:text="@string/show" />

that is my xml file
thanks

  • 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-07T14:39:43+00:00Added an answer on June 7, 2026 at 2:39 pm

    That had me scratching my head for a bit. I had to load your code into eclipse to find it. Change import android.widget.Checkbox; to import android.widget.CheckBox;. (Note the capital B in checkbox.) Your code as posted works fine when I make that change.

    Did eclipse not highlight the offending import? Hovering the mouse cursor over a highlight will give you some clues how to fix it. (forgive me if I sound patronizing. Its hard to tell if someone with a low rep is new to the website or new to the platform)

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

Sidebar

Related Questions

I've been trying to build my first rails app and have gotten stuck on
I'm trying to build my Flex/Java web app from within IntelliJ rather than have
I've been trying to build this small java app. I find it very difficult
I have a basic Valence App build for Desire2Learn and now I'm trying to
I am trying to build a help message output for my custom app like
I've been trying to build an Android app on with Foursquare API. I want
I'm trying to build an educational app that will have approximately 3-5 completely different
I've been trying to build a simple GAE app and to be able to
I've been trying to build pHash(http://phash.org/) on my windows machine and haven't been having
Hey guys, I've been trying to build something simple in Flash 8, and 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.