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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:59:49+00:00 2026-06-08T09:59:49+00:00

Assigning ids to few edit texts results in the following error : the error

  • 0

Assigning ids to few edit texts results in the following error :

the error is in the parameters of findViewById token

Here is the line of code that its on

final EditText myEditField = (EditText) findViewById(R.id.percentText1);

…This is the Xml code sorry again to nerd for posting the java…

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/percentText1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/enterButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="224dp"
        android:onClick="onEnterClick"
        android:text="Calculate Tip" />

    <EditText
        android:id="@+id/percentText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="53dp"
        android:ems="10"
        android:singleLine="true"
        android:text="Percent" />

    <EditText
        android:id="@+id/percentage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/percentText"
        android:layout_alignParentTop="true"
        android:ems="10"
        android:singleLine="true"
        android:text="Bill Amount" >

        <requestFocus />
    </EditText>

</RelativeLayout>

…The Java Code… The error i figure is that i improperly gave the edit text an id…

package tip.calculator;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import tip.calculator.R;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText myEditField = (EditText) findViewById(R.id.percentText); //error here 


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    public void onEnterClick(String args []){


        int percentage;
        int percentageInp;
        int billAmount;
    }


}
  • 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-08T09:59:50+00:00Added an answer on June 8, 2026 at 9:59 am

    Make sure that you dont have this in your imports

    import android.R;
    

    Eclipse sometimes imports this class which instead should be

    import your.application.packagename.R;
    

    usually this happens when we ctrl+shft+o to fix imports. Eclipse adds the R class when we do that. 🙂

    EDIT:

    from your new question, there is a spelling error.
    Try to paste this line inside the onCreate() method:

    EditText myEditField = (EditText) findViewById(R.id.percentText);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm assigning 12 ImageButtons their own ids and then giving each one of 6
When assigning a type casted array to codeigniter's session, I get this error: A
I know normally that assigning a name attribute to the radio inputs would only
I am assigning to an ImageView contacts images using this code: mPhotoView = (ImageView)
Need some help assigning a mouseover event to display some icons that start out
I have some textboxes on a webform that have ids like this: txtFinalDeadline_1 txtFinalDeadline_2
Assigning to id from incompatible type ''CameraVIewController*'' warning showing at the below code UIImagePickerController
I have the following code and it is being killed by a SEGV signal.
The first line of code, called on every one of my application's pages, is:
tl;dr: Is assigning rows IDs of {unixtimestamp}{randomdigits} (such as 1308022796123456) as a BIGINT a

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.