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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:02:58+00:00 2026-06-11T03:02:58+00:00

I am trying to get an int from an edit text set to inputType=number

  • 0

I am trying to get an int from an edit text set to inputType=”number” and then out put it ( i will do something with it later) i cant do it, this is the code i have which i have been told to try but it dose not work

Button go;
EditText num;
TextView OP, ST;
String OPS;
int oer;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    initalize();
    go.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            int myNum = 0;

            OPS = num.getText().toString();

            try {
                myNum = Integer.parseInt(OPS);
            } catch(NumberFormatException nfe) {
                System.out.println("Could not parse " + nfe);
            }
            OP.setText(myNum);
        }

After i run it it force closes.
This Is the LOG CAT:

09-09 16:53:00.400: W/ResourceType(20145): No package identifier when getting value for resource number 0x00000008
09-09 16:53:00.400: D/AndroidRuntime(20145): Shutting down VM
09-09 16:53:00.400: W/dalvikvm(20145): threadid=1: thread exiting with uncaught exception (group=0x40a411f8)
09-09 16:53:00.561: E/AndroidRuntime(20145): FATAL EXCEPTION: main
09-09 16:53:00.561: E/AndroidRuntime(20145): android.content.res.Resources$NotFoundException: String resource ID #0x8
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.content.res.Resources.getText(Resources.java:248)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.widget.TextView.setText(TextView.java:3473)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at com.Nutty.studios.randnumgen.free.RandomNumberGenActivity$1.onClick(RandomNumberGenActivity.java:42)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.view.View.performClick(View.java:3511)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.view.View$PerformClick.run(View.java:14105)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.os.Handler.handleCallback(Handler.java:605)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.os.Handler.dispatchMessage(Handler.java:92)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.os.Looper.loop(Looper.java:137)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at android.app.ActivityThread.main(ActivityThread.java:4575)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at java.lang.reflect.Method.invokeNative(Native Method)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at java.lang.reflect.Method.invoke(Method.java:511)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
09-09 16:53:00.561: E/AndroidRuntime(20145):    at dalvik.system.NativeStart.main(Native Method)

it works fine if i try to out put the string but not as an integer?

  • 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-11T03:03:00+00:00Added an answer on June 11, 2026 at 3:03 am

    1. You will never get an int from EditText, InputType is provided to provide you with the correct softKeyboard…

    2. You can convert the text from EditText in to integer using this..

    int i = Integer.parseInt(editText.getText().toString());

    moreover setText will expect you to provide it with a String…. so you need to do this…

    OP.setText(myNum+"");

    toString() only works with Object types, and as you have declared myNum as int, which is a primitive type…. you need to use + ""

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

Sidebar

Related Questions

From a text file I am trying to get the the 3rd set of
I'm trying to just get rid of duplicate consecutive words from a text file,
I am trying to create a form that will edit rows from my db
I am trying to get this working in Scala: class MyClass(some: Int, func: AnyRef*
So i am trying get 2 div-containers which both should contain centered text (Both
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
Trying to get a wildcard search to pick up on any text in org_name
trying to get same string on tooltip as is in the Text e.g. Text=<%#
I am trying to get one string, two integers and one timepicker result from
I am trying to get all the followersIDs from an a twitter account with

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.