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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:38:07+00:00 2026-05-27T20:38:07+00:00

I have the following app that has a textview and an edittext. When the

  • 0

I have the following app that has a textview and an edittext. When the value of the edittext changes, it updates a textview’s content. Now I want the value to be received as an integer. this is the current app:

package your.test.two;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

public class TesttwoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    EditText input = (EditText)findViewById(R.id.editText1);
    input.addTextChangedListener(new TextWatcher(){
        public void afterTextChanged(Editable s){
            update();
        }
        public void beforeTextChanged(CharSequence s, int start, int count, int after){}
        public void onTextChanged(CharSequence s, int start, int before, int count){}
    });
}

public void update(){
    EditText source = (EditText)findViewById(R.id.editText1);
    Editable sourceData = source.getText();
    TextView destination = (TextView)findViewById(R.id.textView1);
    destination.setText(sourceData);
}
}

Now I want the sourceData editable to be somehow converted to an integer so that I can do a if statement on it as follows:

if(sourceData>255){
  sourceData = 0;
}

I already changed the values of the edittext in main.xml by adding the following lines to editText1:

android:inputType="number"
android:maxLength="3"
android:numeric="integer"

Could someone give me a few guidelines as to how this can be done please. Been googling it but all I end up with is things like:

Integer i = Integer.parseInt(edittext.gettext().tostring());

&

Integer i = Integer.valueOf(String s);

And I don’t quite get those to work or understand it. Please help!? 🙁

  • 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-05-27T20:38:07+00:00Added an answer on May 27, 2026 at 8:38 pm

    You should be able to use

    Integer i = Integer.parseInt(edittext.gettext().tostring());
    

    By replacing i with the variable you want to set the integer to, in your case “sourceData”, and by replacing edittext with the name of your edittext box, so “source”

    So you’d get something like this:

    public void update(){
        EditText source = (EditText)findViewById(R.id.editText1);
        Integer sourceData = Integer.parseInt(source.getText().toString());
        TextView destination = (TextView)findViewById(R.id.textView1);
        destination.setText(Integer.toString(sourceData));
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new iPhone app that has the following (and only the following)
I have an app that has the following in the routes file: namespace admin
This is a simplification, but I have an app that has the following methods:
I have a web app that has the following models: Shifts, Years, Checkouts, Sales
I have the following section of code in an app that I am writing:
I have an app that has a UINavigationController that pushes a UITabBarController into view.
I have a Java app that has an embedded Derby database (no hibernate though).
I have a winforms c# app that has an embedded webbrowser control inside it
I'm working on an app that has rows in the following format. I've numbered
We have an application that has a launcher app that sits there with 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.