How to get multiple integer values from EditText in Activity A to show min and max in TextView in Activity B?










1














This is regarding to an app in android studio that i'm building.
I have 2 activities.



In activity A, I have 4 EditTexts that can only contain integer.
Min button:there is a button, that should calculate the minimum of those 4 numbers entered by user.
Max button:there is a button, that should calculate the maximum of those 4 numbers entered by user.



In activity B, there are 6 TextViews (4 for numbers, 2 for Min and Max).
When the Button in Activity A is pressed. It should pass the numbers from the EditTexts in Activity A to the TextViews in Activity B. In addition to that, it should show the average of the 4 numbers in Results TextView.



I figured out the way how to pass the numbers to the TextViews in the second Activity.
What I want is a code that calculates the min and max of the user inputs and shows the min and max result in the TextView in Activity B.










share|improve this question




























    1














    This is regarding to an app in android studio that i'm building.
    I have 2 activities.



    In activity A, I have 4 EditTexts that can only contain integer.
    Min button:there is a button, that should calculate the minimum of those 4 numbers entered by user.
    Max button:there is a button, that should calculate the maximum of those 4 numbers entered by user.



    In activity B, there are 6 TextViews (4 for numbers, 2 for Min and Max).
    When the Button in Activity A is pressed. It should pass the numbers from the EditTexts in Activity A to the TextViews in Activity B. In addition to that, it should show the average of the 4 numbers in Results TextView.



    I figured out the way how to pass the numbers to the TextViews in the second Activity.
    What I want is a code that calculates the min and max of the user inputs and shows the min and max result in the TextView in Activity B.










    share|improve this question


























      1












      1








      1







      This is regarding to an app in android studio that i'm building.
      I have 2 activities.



      In activity A, I have 4 EditTexts that can only contain integer.
      Min button:there is a button, that should calculate the minimum of those 4 numbers entered by user.
      Max button:there is a button, that should calculate the maximum of those 4 numbers entered by user.



      In activity B, there are 6 TextViews (4 for numbers, 2 for Min and Max).
      When the Button in Activity A is pressed. It should pass the numbers from the EditTexts in Activity A to the TextViews in Activity B. In addition to that, it should show the average of the 4 numbers in Results TextView.



      I figured out the way how to pass the numbers to the TextViews in the second Activity.
      What I want is a code that calculates the min and max of the user inputs and shows the min and max result in the TextView in Activity B.










      share|improve this question















      This is regarding to an app in android studio that i'm building.
      I have 2 activities.



      In activity A, I have 4 EditTexts that can only contain integer.
      Min button:there is a button, that should calculate the minimum of those 4 numbers entered by user.
      Max button:there is a button, that should calculate the maximum of those 4 numbers entered by user.



      In activity B, there are 6 TextViews (4 for numbers, 2 for Min and Max).
      When the Button in Activity A is pressed. It should pass the numbers from the EditTexts in Activity A to the TextViews in Activity B. In addition to that, it should show the average of the 4 numbers in Results TextView.



      I figured out the way how to pass the numbers to the TextViews in the second Activity.
      What I want is a code that calculates the min and max of the user inputs and shows the min and max result in the TextView in Activity B.







      java android android-studio






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 at 1:39

























      asked Nov 12 at 20:45









      FrancoMedicci

      63




      63






















          1 Answer
          1






          active

          oldest

          votes


















          0














          First, you will need to get the numbers from all of your Textview and set them in Integer List, After that, you can check the numbers using Collections



          And the following is the example code for that:



           List<Integer> list = Arrays.asList(100,2,3,4,5,6,7,67,2,32);

          int min = Collections.min(list);
          int max = Collections.max(list);

          System.out.println(min);
          System.out.println(max);


          Output:



          2
          100


          Of course, you will have to set the output in Textview instead of System.out.println






          share|improve this answer




















          • well in my case i don't know the numbers. when the app starts the editTexts are empty then user enter the numbers in 4 editTexts and then i should get the min and max of these 4 numbers that are entered by user. i don't know what code to use to get the min and max value of 4 numbers.
            – FrancoMedicci
            Nov 13 at 1:48










          • you dont need to know the numbers that was just example, what you need to do is: when the user click on Min Button check every edittext you have if its not empty it will take the number in it and put it in the array and than move to next edittext do the same thing and move to next untill you finish with checking and than you run my code and if all of the values are empty and theres nothing in the array list than theres no point to run the code, instead you can show Toast and tell the user he need to give input first
            – hossam scott
            Nov 13 at 9:07






          • 1




            thanks i used the collections and it works.
            – FrancoMedicci
            Nov 13 at 14:42










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269838%2fhow-to-get-multiple-integer-values-from-edittext-in-activity-a-to-show-min-and-m%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          First, you will need to get the numbers from all of your Textview and set them in Integer List, After that, you can check the numbers using Collections



          And the following is the example code for that:



           List<Integer> list = Arrays.asList(100,2,3,4,5,6,7,67,2,32);

          int min = Collections.min(list);
          int max = Collections.max(list);

          System.out.println(min);
          System.out.println(max);


          Output:



          2
          100


          Of course, you will have to set the output in Textview instead of System.out.println






          share|improve this answer




















          • well in my case i don't know the numbers. when the app starts the editTexts are empty then user enter the numbers in 4 editTexts and then i should get the min and max of these 4 numbers that are entered by user. i don't know what code to use to get the min and max value of 4 numbers.
            – FrancoMedicci
            Nov 13 at 1:48










          • you dont need to know the numbers that was just example, what you need to do is: when the user click on Min Button check every edittext you have if its not empty it will take the number in it and put it in the array and than move to next edittext do the same thing and move to next untill you finish with checking and than you run my code and if all of the values are empty and theres nothing in the array list than theres no point to run the code, instead you can show Toast and tell the user he need to give input first
            – hossam scott
            Nov 13 at 9:07






          • 1




            thanks i used the collections and it works.
            – FrancoMedicci
            Nov 13 at 14:42















          0














          First, you will need to get the numbers from all of your Textview and set them in Integer List, After that, you can check the numbers using Collections



          And the following is the example code for that:



           List<Integer> list = Arrays.asList(100,2,3,4,5,6,7,67,2,32);

          int min = Collections.min(list);
          int max = Collections.max(list);

          System.out.println(min);
          System.out.println(max);


          Output:



          2
          100


          Of course, you will have to set the output in Textview instead of System.out.println






          share|improve this answer




















          • well in my case i don't know the numbers. when the app starts the editTexts are empty then user enter the numbers in 4 editTexts and then i should get the min and max of these 4 numbers that are entered by user. i don't know what code to use to get the min and max value of 4 numbers.
            – FrancoMedicci
            Nov 13 at 1:48










          • you dont need to know the numbers that was just example, what you need to do is: when the user click on Min Button check every edittext you have if its not empty it will take the number in it and put it in the array and than move to next edittext do the same thing and move to next untill you finish with checking and than you run my code and if all of the values are empty and theres nothing in the array list than theres no point to run the code, instead you can show Toast and tell the user he need to give input first
            – hossam scott
            Nov 13 at 9:07






          • 1




            thanks i used the collections and it works.
            – FrancoMedicci
            Nov 13 at 14:42













          0












          0








          0






          First, you will need to get the numbers from all of your Textview and set them in Integer List, After that, you can check the numbers using Collections



          And the following is the example code for that:



           List<Integer> list = Arrays.asList(100,2,3,4,5,6,7,67,2,32);

          int min = Collections.min(list);
          int max = Collections.max(list);

          System.out.println(min);
          System.out.println(max);


          Output:



          2
          100


          Of course, you will have to set the output in Textview instead of System.out.println






          share|improve this answer












          First, you will need to get the numbers from all of your Textview and set them in Integer List, After that, you can check the numbers using Collections



          And the following is the example code for that:



           List<Integer> list = Arrays.asList(100,2,3,4,5,6,7,67,2,32);

          int min = Collections.min(list);
          int max = Collections.max(list);

          System.out.println(min);
          System.out.println(max);


          Output:



          2
          100


          Of course, you will have to set the output in Textview instead of System.out.println







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 21:03









          hossam scott

          1




          1











          • well in my case i don't know the numbers. when the app starts the editTexts are empty then user enter the numbers in 4 editTexts and then i should get the min and max of these 4 numbers that are entered by user. i don't know what code to use to get the min and max value of 4 numbers.
            – FrancoMedicci
            Nov 13 at 1:48










          • you dont need to know the numbers that was just example, what you need to do is: when the user click on Min Button check every edittext you have if its not empty it will take the number in it and put it in the array and than move to next edittext do the same thing and move to next untill you finish with checking and than you run my code and if all of the values are empty and theres nothing in the array list than theres no point to run the code, instead you can show Toast and tell the user he need to give input first
            – hossam scott
            Nov 13 at 9:07






          • 1




            thanks i used the collections and it works.
            – FrancoMedicci
            Nov 13 at 14:42
















          • well in my case i don't know the numbers. when the app starts the editTexts are empty then user enter the numbers in 4 editTexts and then i should get the min and max of these 4 numbers that are entered by user. i don't know what code to use to get the min and max value of 4 numbers.
            – FrancoMedicci
            Nov 13 at 1:48










          • you dont need to know the numbers that was just example, what you need to do is: when the user click on Min Button check every edittext you have if its not empty it will take the number in it and put it in the array and than move to next edittext do the same thing and move to next untill you finish with checking and than you run my code and if all of the values are empty and theres nothing in the array list than theres no point to run the code, instead you can show Toast and tell the user he need to give input first
            – hossam scott
            Nov 13 at 9:07






          • 1




            thanks i used the collections and it works.
            – FrancoMedicci
            Nov 13 at 14:42















          well in my case i don't know the numbers. when the app starts the editTexts are empty then user enter the numbers in 4 editTexts and then i should get the min and max of these 4 numbers that are entered by user. i don't know what code to use to get the min and max value of 4 numbers.
          – FrancoMedicci
          Nov 13 at 1:48




          well in my case i don't know the numbers. when the app starts the editTexts are empty then user enter the numbers in 4 editTexts and then i should get the min and max of these 4 numbers that are entered by user. i don't know what code to use to get the min and max value of 4 numbers.
          – FrancoMedicci
          Nov 13 at 1:48












          you dont need to know the numbers that was just example, what you need to do is: when the user click on Min Button check every edittext you have if its not empty it will take the number in it and put it in the array and than move to next edittext do the same thing and move to next untill you finish with checking and than you run my code and if all of the values are empty and theres nothing in the array list than theres no point to run the code, instead you can show Toast and tell the user he need to give input first
          – hossam scott
          Nov 13 at 9:07




          you dont need to know the numbers that was just example, what you need to do is: when the user click on Min Button check every edittext you have if its not empty it will take the number in it and put it in the array and than move to next edittext do the same thing and move to next untill you finish with checking and than you run my code and if all of the values are empty and theres nothing in the array list than theres no point to run the code, instead you can show Toast and tell the user he need to give input first
          – hossam scott
          Nov 13 at 9:07




          1




          1




          thanks i used the collections and it works.
          – FrancoMedicci
          Nov 13 at 14:42




          thanks i used the collections and it works.
          – FrancoMedicci
          Nov 13 at 14:42

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269838%2fhow-to-get-multiple-integer-values-from-edittext-in-activity-a-to-show-min-and-m%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党