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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:20:40+00:00 2026-05-30T02:20:40+00:00

I am trying to figure out if there is a way to call submitValue,

  • 0

I am trying to figure out if there is a way to call “submitValue”, made in createNewSubmitButton(); in the onCreate(); function?

So I want to submit the value in EditText to a TextView when you hit the Button submit value, so I set a onClick in there, but I couldn’t call submitValue in onCreate?

See my code example to see what I mean:

package com.lars.myApp;

import com.lars.myApp.R;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.view.View;
import android.view.View.OnClickListener;

public class myAppActivity extends Activity {

    int currentValue =  0;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final EditText valueOne = (EditText) findViewById(R.id.valueOne);
        Button addOne = (Button) findViewById(R.id.addOne);
        Button minusOne = (Button) findViewById(R.id.minusOne);

        Button addButton = (Button) findViewById(R.id.add);
        final TableLayout tableLayout1 = (TableLayout) findViewById(R.id.tableLayout1);

        TextView textView = new TextView(this);
        textView.setText("New text");

        addOne.setOnClickListener(new OnClickListener(){
            public void onClick(View v) {
                addValue();
                valueOne.setText("" + currentValue);
            }
        });

        minusOne.setOnClickListener(new OnClickListener(){
            public void onClick(View v) {
                minusValue();
                valueOne.setText("" + currentValue);
            }
        });

        addButton.setOnClickListener(new OnClickListener(){
            public void onClick(View v) {
                tableLayout1.addView(createNewRow());
            }
        });


        // I OUTCOMMENTED THIS, BECAUSE IT DIDN'T WORK, submitValue: "CANNOT BE RESOLVED"

        /*submitValue.setOnClickListener(new OnClickListener(){
            public void onClick(View v) {
                tableLayout1.addView(createNewTextView(newValue.getText().toString()));
            }

        });*/

    }

    public TableRow createNewRow() {
        final TableRow newRow = new TableRow(this);
        newRow.addView(createNewContainer());
        return newRow;
    }

    public LinearLayout createNewContainer(){
        final LinearLayout newContainer = new LinearLayout(this);
        newContainer.addView(createNewEditableText());
        newContainer.addView(createNewSubmitButton());
        return newContainer;
    }    
    public EditText createNewEditableText() {
        final EditText newValue = new EditText(this);
        newValue.setHint("New");
        return newValue;
    }

    public Button createNewSubmitButton(){
        final Button submitValue = new Button(this);
        submitValue.setText("Submit");
        return submitValue;
    }

    public TextView createNewTextView(String text) {
        final TextView textView = new TextView(this);
        textView.setText(text);
        return textView;
    }

    public void addValue(){
        if(currentValue <= 999){
        currentValue = currentValue + 1;
        }
    }  

    public void minusValue(){
        if(currentValue >= 1){
            currentValue = currentValue - 1;
        }
    }  
}

I hope someone can help me

  • 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-30T02:20:41+00:00Added an answer on May 30, 2026 at 2:20 am

    In fact, you can’t call somthing that isn’t yet created in your view.

    Still you have 2 options :

    A – Create it in your onCreate(...) but add it later to your view

    B- Create it, add it but use the folowing parameter :

    sibmitButton.setVisibility(View.GONE);
    

    The thing cool with this i that you can add the button, play with it (programmatically) but the user can’t touch it ! It even doesn’t take any ‘space’ on your view !

    And when needed, just use :

    sibmutButton.setVisibility(View.VISIBLE);
    

    Is it what you want ?

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

Sidebar

Related Questions

I'm trying to figure out if there's a way I can search for a
I'm trying to figure out if there's a way to use jquery's slideDown/slideUp/slideToggle functions
I'm trying to figure out if there is a way (using JavaScript, or jQuery
I'm trying to figure out if there is an easy way to do the
I'm trying to figure out how if there's a way to make a hostname
I've been trying to figure this out all morning. Is there a way to
I am trying to figure out how to call a Python function from a
Im trying to figure out if there is a way to do the following
I'm trying to figure out if there is an easy way implementing a retry
I'm trying to figure out the best way to create a row of three

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.