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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:51:35+00:00 2026-06-07T23:51:35+00:00

I am not a programmer I just like to make apps that help me

  • 0

I am not a programmer I just like to make apps that help me for my work so I dont know alot about programming properly. That being said this is what I am up against. I enter a number for 1 to 100 and then my app will create a scrollable tablelayout with that many rows. Each row has a textview, an edittext and another textview here my code:

TableLayout tL = (TableLayout)findViewById(R.id.tableLayout1);
    // creates all the fields
    for(int i = 1; i <= numOfInjWells; i++) {
        TableRow tR = new TableRow(this);
        // creates the textView
        TextView tV1 = new TextView(this);
        tV1.setText("      " + i + ":    ");

        // add edit text
        EditText eT = new EditText(this);
        eT.setText("Meter Reading");
        eT.setInputType(InputType.TYPE_CLASS_NUMBER);

        TextView tV2 = new TextView(this);
        tV2.setText("");

        // add the TextView and the editText to the new TableRow
        tR.addView(tV1);
        tR.addView(eT);
        tR.addView(tV2);

        // add the TableRow to the TableLayout
        tL.addView(tR,new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));    
    } // end for statement

so when I input a number in the edittext (eT) of row one I want it to then calculate the difference between it and a number I have stored in my database (I already know how to get the specific number I need from the database) and then change the textview tV2 in row one so it displays the difference without clicking a button. The problem that I am coming across is how do I associate edittext (eT) in row one with textview (tV2) because all the edittext and textviews have the same name eT or tV2

thanks for you help and I am sorry that I dont know much about coding.

edit: I thought about adding

eT.setId(i);
tV2.setId(i); 

but I dont know how to use that in my calculations.

  • 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-07T23:51:37+00:00Added an answer on June 7, 2026 at 11:51 pm

    After looking into listview I couldnt get them to work with the edittext so I went back to my tablelayout and this is the final working version.

    Here I create the fields and a textwatcher added to the edittext to watch for changes:

        TableLayout tL = (TableLayout)findViewById(R.id.tableLayout1);
        // creates all the fields
        for(int i = 1; i <= numOfInjWells; i++) {
            TableRow tR = new TableRow(this);
            // creates the textView
            TextView tV1 = new TextView(this);
            tV1.setText("       " + i + ":    ");
    
            // add edit text
            eT = new EditText(this);
            eT.setInputType(InputType.TYPE_CLASS_NUMBER);
            eT.setWidth(100);
            eT.setId(1000 + i);
            eT.addTextChangedListener(new CustomTextWatcher(eT));
    
            tV2 = new TextView(this);
            tV2.setText("");
            tV2.setId(2000 + i);
    
            // add the TextView and the editText to the new TableRow
            tR.addView(tV1);
            tR.addView(eT);
            tR.addView(tV2);
    
            // add the TableRow to the TableLayout
            tL.addView(tR,new TableLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));    
        } // end for statement
    

    next I created this class for my customtextwachter:

    private class CustomTextWatcher implements TextWatcher {
        private EditText mEditText;
    
        public CustomTextWatcher(EditText eT) {
            mEditText = eT;
        }
    
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    
        public void afterTextChanged(Editable s) {
            // gets the change amount for each meter reading from the previous reading
                // this method does the work
            getMeterChange();
    
        }
    } // end class CustomTextWatcher
    

    the getMeterChange() method does the work:

    public void getMeterChange() {
        int preMeterReading = 0;
        int mReading = 0;
    
        try {
            cRWLogData.moveToPosition(recordLookUp - 1);
            preMeterReading = cRWLogData.getInt( 14 + rowChanged);
            // finds the edittext that has focus
            View currView = tL.findFocus();
            int currentid = tL.findFocus().getId();
            // gets the string from the edittext and changes it to a int
            EditText currentComponent = (EditText) currView;
            String eTValue = currentComponent.getText().toString();
            mReading = Integer.parseInt(eTValue);
            // calculates difference for what is entered and what is in database
            mChange = mReading - preMeterReading;
            // makes the textview in the same tablerow as the edittext active
            TextView tV2 = (TextView) findViewById(currentid + 1000);
            // sets the text of the textview
            tV2.setText("     " + mChange +"");
        } // end try
        catch (Exception e) {}
    
    } // end getMeterChange
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not an experinced c++ programmer. So I just want to know how
I am a systems programmer, so i just know some basic css/html. I like
(DISCLAIMER: I'm not a programmer, I spend my time on serverfault, I'm just a
I have an issue and NO it is not homework, it's just a programmer
I am not professional programmer so i can not be sure about this.How many
I've been struggling with something at work that I'm not really in the mood
I am not a programmer, I just a web designer with a bit of
I know this is not exactly reflection, but kind of. I want to make
DISCLAIMER: I'm still an uber-n00b with programming concepts and know just enough VBS to
I'm not a great programmer, to me it's just a hobby. I am more

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.