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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:26:59+00:00 2026-06-02T15:26:59+00:00

button = new Button (this); button.setText(Insert values); tableLayout.addView(secondo); button.setOnClickListener(new OnClickListener(){ public void onClick(View arg0)

  • 0
button = new Button (this);
button.setText("Insert values");
tableLayout.addView(secondo);

button.setOnClickListener(new OnClickListener(){
    public void onClick(View arg0) {
        for(int i = 0; i < r1; i++){
            for(int j = 0; j < c1;  j++){
                //insert values from a matrix of edittext in array      
                array[t] = Integer.parseInt(values[i][j].getText().toString()); 
                t++;
            }
        }
    }       
});

I want to put in this code a control on the input of values by edittext, that show me an alert when the values in input is incorrect, because now the app crash when the input is incorrect. Thanks

  • 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-02T15:27:01+00:00Added an answer on June 2, 2026 at 3:27 pm
    try {
        for(int i = 0; i < r1; i++){
            for(int j = 0; j < c1;  j++){
                //insert values from a matrix of edittext in array
                array[t] = Integer.parseInt(values[i][j].getText().toString());
                t++;
            }
        }
    }
    catch(NumberFormatException nfe) {
        AlertDialog.Builder builder;
        builder = new AlertDialog.Builder(MyActivityClassName.this);
        builder.setTitle("Error");
        builder.setMessage("Wrong input format"); 
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        builder.show();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // fileReader(); new xyz().execute(); }//
Button myButton = new Button(this); myButton.setText(Change View); myButton.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); myButton.setOnClickListener(new OnClickListener() { public
I create button like this: Button button = new Button(this); button.setText(2012); button.setBackgroundColor(Color.TRANSPARENT); button.setOnClickListener(mCorkyListener); layout.addView(dateButton);
Button b1 = new Button(this); b1.setText(R.string.hello); RelativeLayout layout1 = (RelativeLayout) findViewById(R.id.top_menu); //android:layout_alignParentRight=true layout1.addView(b1); Is
for( i=0; i<26; i++) { btnAlpha[i] = new Button(this); btnAlpha[i].setBackgroundColor(Color.TRANSPARENT); btnAlpha[i].setTextColor(Color.GREEN); btnAlpha[i].setText(Character.toString ((char)(j+i))); btnAlpha[i].setOnClickListener(new
If we add event listener to a button in java like this : btn.setOnClickListener(new
Button btn = new Button(this); btn.setText(This is a Button); btn.setLayoutParams(params); What will happen if
Code: Button b = new Button(this); b.setText(m.group()); RelativeLayout.LayoutParams lP = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
TableLayout relativeLayout = (TableLayout)findViewById(R.id.ll1); TableRow row =new TableRow(this); Button button ; int counter =
I have 2 radio button with values New & Existing. If user chooses New,

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.