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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:58:43+00:00 2026-06-17T08:58:43+00:00

Iam a beginner in android project development. I have started developing a basic app

  • 0

Iam a beginner in android project development. I have started developing a basic app using a tutorial i found online. Im using eclipse.There were no errors while running my project. Im getting this error immediately after i click the app on my emulator. Following r d xml and java coding i used:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/tvDisplay"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="@string/result"
    android:textSize="30sp" />

<Button
    android:id="@+id/a"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="@string/add"
    android:textSize="20sp" />

<Button
    android:id="@+id/s"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="@string/sub"
    android:textSize="20sp" /></LinearLayout>

Java:

package com.app.myapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

int count;
Button add,sub;
TextView disp;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.linear);
    count=0;
    add=(Button) findViewById(R.id.a);
    sub=(Button) findViewById(R.id.s);
    disp=(Button) findViewById(R.id.tvDisplay);
    add.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            count=count+1;
            disp.setText("Result is " + count);

        }
    });
    sub.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            count=count-1;
            disp.setText("Result is " + count);
        }
    });
}
}

Kindly suggest solutions after which I should proceed my project development.

  • 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-17T08:58:44+00:00Added an answer on June 17, 2026 at 8:58 am
    TextView disp;
    disp=(Button) findViewById(R.id.tvDisplay);
    

    You have declared ‘disp’ as a TextView;
    But in the code you cast it to a Button. Change the cast to TextView like this :

    disp=(TextView) findViewById(R.id.tvDisplay);

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

Sidebar

Related Questions

I am a beginner of Android apps and am using Eclipse. I have found
I am a beginner in Android development, and I have to continue a project
i am beginner in Android app development i am working on a app which
I am beginner in android application development. If i am using n number of
Iam beginner in android game development and i'm currently having some trouble on drawing
I am building an android app. Eclipse lists my android version of the project
I am a beginner in Android development and starting my second Android project -
First off I am a beginner in Android development; I have been doing a
I am a beginner in Android game development, while searching i found Rokon, a
I am a beginner in android. I have registered an app to twitter and

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.