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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:49:26+00:00 2026-06-17T20:49:26+00:00

I have created edittext dynamically when i enter the values i am unable to

  • 0

I have created edittext dynamically when i enter the values i am unable to display values the values.If suppose i want add values that i have entered in edit text how is it possible do i need to give for loop.

Here is the code

 public class NewActivity extends Activity {

LinearLayout ll;

   EditText lEditText; 

   public void onCreate(Bundle savedInstanceState) {

   super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

        ll=new LinearLayout(this);

            ll=(LinearLayout)findViewById(R.id.my);

            Button lButton = (Button)findViewById(R.id.mybtnid);

            lButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {

            lEditText = new EditText(getApplicationContext());

            lEditText.setHint("Text Here");

            lEditText.setInputType(InputType.TYPE_CLASS_NUMBER);

            ll.addView(lEditText);


                 }
                });

        Button button1=(Button)findViewById(R.id.btn2);
            button1.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                            TextView tv = new TextView(getApplication());

                          int x=Integer.parseInt(lEditText.getText().toString());

                          tv.setText(x);

                         ll.addView(tv);

            }
        });

I am getting errors in logcat as :

    AndroidRuntime(509): android.content.res.Resources$NotFoundException: String resource ID #0x1
    E/AndroidRuntime(509):  at android.content.res.Resources.getText(Resources.java:201)
    E/AndroidRuntime(509):  at android.widget.TextView.setText(TextView.java:2817)
    E/AndroidRuntime(509):  at com.app.NewActivity$2.onClick(NewActivity.java:44)
    E/AndroidRuntime(509):  at android.view.View.performClick(View.java:2408)
    E/AndroidRuntime(509):  at android.view.View$PerformClick.run(View.java:8816)
    E/AndroidRuntime(509):  at android.os.Handler.handleCallback(Handler.java:587)
    E/AndroidRuntime(509):  at android.os.Handler.dispatchMessage(Handler.java:92)
    E/AndroidRuntime(509):  at android.os.Looper.loop(Looper.java:123)
    E/AndroidRuntime(509):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    E/AndroidRuntime(509):  at java.lang.reflect.Method.invokeNative(Native Method)
    E/AndroidRuntime(509):  at java.lang.reflect.Method.invoke(Method.java:521)
    E/AndroidRuntime(509):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    E/AndroidRuntime(509):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    E/AndroidRuntime(509):  at dalvik.system.NativeStart.main(Native Method)
  • 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-17T20:49:27+00:00Added an answer on June 17, 2026 at 8:49 pm

    Try to make changes as below to set the text in your TextView

     int x=Integer.parseInt(lEditText.getText().toString());
       tv.setText(x+""); <-- Add "" to set the integer value in your textview.
    

    EDITED:

    Try out below code for your dynamically adding values:

       final EditText et1=(EditText)findViewById(R.id.editText1);
       final EditText et2=(EditText)findViewById(R.id.editText3);
        Button bt=(Button)findViewById(R.id.button1);
        bt.setOnClickListener(new OnClickListener() {           
            @Override
            public void onClick(View arg0) {
                try
                {
                int x=Integer.valueOf(et1.getText().toString());
                int y= Integer.valueOf(et2.getText().toString());
                int z=x+y;
                System.err.println(z+"");
                        tv.setText(z+""); 
                }
                catch (NumberFormatException e) {
                    // TODO: handle exception
                }
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a slider that let's me dynamically add a number of EditText fields.
I have a button on my home screen that will add an edit text
I have created EditText views Dynamically now I want to get their texts into
I have a listview that contain several EditTexts created dynamically according to the number
I have created a filter listview where user will enter input via edittext and
I have an Array of dynamically created EditText in Java and I have a
I'm new in android and i have created editText dynamically with the following code
I have a created an EditText. I can know text change using TextChangedListener. But
I have created one keyboard.When user enter numbers , its entering particular EditText.But When
I have dynamically created LinearLayout and radiobutton in each linearlayout... but i want to

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.