How to calculate min value of 4 EditTexts in Android?












0














This is an app.
I have 4 EditTexts. which the user enter the number.
There is a min button.



When the user clicks on the min button, it should calculate the minimum of the 4 numbers that were entered by the users.










share|improve this question
























  • what have you tried ? Have you successfully get the text from editText ?
    – John Joe
    Nov 13 '18 at 3:29












  • I figured out that part. i'm stuck in getting the result and showing it in the textview.
    – FrancoMedicci
    Nov 13 '18 at 3:46










  • post the code so we can help
    – John Joe
    Nov 13 '18 at 3:46






  • 1




    This sounds like homework.
    – majidarif
    Nov 13 '18 at 6:05












  • I figured it out and yes this is an assignment.
    – FrancoMedicci
    Nov 14 '18 at 0:32
















0














This is an app.
I have 4 EditTexts. which the user enter the number.
There is a min button.



When the user clicks on the min button, it should calculate the minimum of the 4 numbers that were entered by the users.










share|improve this question
























  • what have you tried ? Have you successfully get the text from editText ?
    – John Joe
    Nov 13 '18 at 3:29












  • I figured out that part. i'm stuck in getting the result and showing it in the textview.
    – FrancoMedicci
    Nov 13 '18 at 3:46










  • post the code so we can help
    – John Joe
    Nov 13 '18 at 3:46






  • 1




    This sounds like homework.
    – majidarif
    Nov 13 '18 at 6:05












  • I figured it out and yes this is an assignment.
    – FrancoMedicci
    Nov 14 '18 at 0:32














0












0








0







This is an app.
I have 4 EditTexts. which the user enter the number.
There is a min button.



When the user clicks on the min button, it should calculate the minimum of the 4 numbers that were entered by the users.










share|improve this question















This is an app.
I have 4 EditTexts. which the user enter the number.
There is a min button.



When the user clicks on the min button, it should calculate the minimum of the 4 numbers that were entered by the users.







java android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 6:05









Shashanth

2,49642136




2,49642136










asked Nov 13 '18 at 3:28









FrancoMedicci

63




63












  • what have you tried ? Have you successfully get the text from editText ?
    – John Joe
    Nov 13 '18 at 3:29












  • I figured out that part. i'm stuck in getting the result and showing it in the textview.
    – FrancoMedicci
    Nov 13 '18 at 3:46










  • post the code so we can help
    – John Joe
    Nov 13 '18 at 3:46






  • 1




    This sounds like homework.
    – majidarif
    Nov 13 '18 at 6:05












  • I figured it out and yes this is an assignment.
    – FrancoMedicci
    Nov 14 '18 at 0:32


















  • what have you tried ? Have you successfully get the text from editText ?
    – John Joe
    Nov 13 '18 at 3:29












  • I figured out that part. i'm stuck in getting the result and showing it in the textview.
    – FrancoMedicci
    Nov 13 '18 at 3:46










  • post the code so we can help
    – John Joe
    Nov 13 '18 at 3:46






  • 1




    This sounds like homework.
    – majidarif
    Nov 13 '18 at 6:05












  • I figured it out and yes this is an assignment.
    – FrancoMedicci
    Nov 14 '18 at 0:32
















what have you tried ? Have you successfully get the text from editText ?
– John Joe
Nov 13 '18 at 3:29






what have you tried ? Have you successfully get the text from editText ?
– John Joe
Nov 13 '18 at 3:29














I figured out that part. i'm stuck in getting the result and showing it in the textview.
– FrancoMedicci
Nov 13 '18 at 3:46




I figured out that part. i'm stuck in getting the result and showing it in the textview.
– FrancoMedicci
Nov 13 '18 at 3:46












post the code so we can help
– John Joe
Nov 13 '18 at 3:46




post the code so we can help
– John Joe
Nov 13 '18 at 3:46




1




1




This sounds like homework.
– majidarif
Nov 13 '18 at 6:05






This sounds like homework.
– majidarif
Nov 13 '18 at 6:05














I figured it out and yes this is an assignment.
– FrancoMedicci
Nov 14 '18 at 0:32




I figured it out and yes this is an assignment.
– FrancoMedicci
Nov 14 '18 at 0:32












3 Answers
3






active

oldest

votes


















1














You could use Collections.min:



List<Integer> numbers = new ArrayList<>()
numbers.add(...) // parse your text to int

int minimum = Collections.min(numbers);





share|improve this answer





























    0














    First, you have to get values from 4 EditText, then parse String to Int



        int num1, num2, num3, num4;
    try {
    num1 = Integer.parseInt(editText1.getText().trim().toString());
    num2 = Integer.parseInt(editText2.getText().trim().toString());
    num3 = Integer.parseInt(editText3.getText().trim().toString());
    num4 = Integer.parseInt(editText4.getText().trim().toString());
    } catch (Exception e) {
    // Handle error here
    }


    You can easily find min from the integers then



    textView.setText(String.valueOf(min))





    share|improve this answer





























      0














      min.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      List<Integer> numbers = new ArrayList<>();
      numbers.add(Integer.parseInt(editText1.getText().trim().toString()));
      numbers.add(Integer.parseInt(editText2.getText().trim().toString()));
      numbers.add(Integer.parseInt(editText3.getText().trim().toString()));
      numbers.add(Integer.parseInt(editText4.getText().trim().toString()));
      min.setText(String.valueOf(Collections.min(numbers)));}
      });





      share|improve this answer





















        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%2f53273358%2fhow-to-calculate-min-value-of-4-edittexts-in-android%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        You could use Collections.min:



        List<Integer> numbers = new ArrayList<>()
        numbers.add(...) // parse your text to int

        int minimum = Collections.min(numbers);





        share|improve this answer


























          1














          You could use Collections.min:



          List<Integer> numbers = new ArrayList<>()
          numbers.add(...) // parse your text to int

          int minimum = Collections.min(numbers);





          share|improve this answer
























            1












            1








            1






            You could use Collections.min:



            List<Integer> numbers = new ArrayList<>()
            numbers.add(...) // parse your text to int

            int minimum = Collections.min(numbers);





            share|improve this answer












            You could use Collections.min:



            List<Integer> numbers = new ArrayList<>()
            numbers.add(...) // parse your text to int

            int minimum = Collections.min(numbers);






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 13 '18 at 3:39









            Aaron

            1,6831212




            1,6831212

























                0














                First, you have to get values from 4 EditText, then parse String to Int



                    int num1, num2, num3, num4;
                try {
                num1 = Integer.parseInt(editText1.getText().trim().toString());
                num2 = Integer.parseInt(editText2.getText().trim().toString());
                num3 = Integer.parseInt(editText3.getText().trim().toString());
                num4 = Integer.parseInt(editText4.getText().trim().toString());
                } catch (Exception e) {
                // Handle error here
                }


                You can easily find min from the integers then



                textView.setText(String.valueOf(min))





                share|improve this answer


























                  0














                  First, you have to get values from 4 EditText, then parse String to Int



                      int num1, num2, num3, num4;
                  try {
                  num1 = Integer.parseInt(editText1.getText().trim().toString());
                  num2 = Integer.parseInt(editText2.getText().trim().toString());
                  num3 = Integer.parseInt(editText3.getText().trim().toString());
                  num4 = Integer.parseInt(editText4.getText().trim().toString());
                  } catch (Exception e) {
                  // Handle error here
                  }


                  You can easily find min from the integers then



                  textView.setText(String.valueOf(min))





                  share|improve this answer
























                    0












                    0








                    0






                    First, you have to get values from 4 EditText, then parse String to Int



                        int num1, num2, num3, num4;
                    try {
                    num1 = Integer.parseInt(editText1.getText().trim().toString());
                    num2 = Integer.parseInt(editText2.getText().trim().toString());
                    num3 = Integer.parseInt(editText3.getText().trim().toString());
                    num4 = Integer.parseInt(editText4.getText().trim().toString());
                    } catch (Exception e) {
                    // Handle error here
                    }


                    You can easily find min from the integers then



                    textView.setText(String.valueOf(min))





                    share|improve this answer












                    First, you have to get values from 4 EditText, then parse String to Int



                        int num1, num2, num3, num4;
                    try {
                    num1 = Integer.parseInt(editText1.getText().trim().toString());
                    num2 = Integer.parseInt(editText2.getText().trim().toString());
                    num3 = Integer.parseInt(editText3.getText().trim().toString());
                    num4 = Integer.parseInt(editText4.getText().trim().toString());
                    } catch (Exception e) {
                    // Handle error here
                    }


                    You can easily find min from the integers then



                    textView.setText(String.valueOf(min))






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 13 '18 at 4:33









                    Liar

                    858514




                    858514























                        0














                        min.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                        List<Integer> numbers = new ArrayList<>();
                        numbers.add(Integer.parseInt(editText1.getText().trim().toString()));
                        numbers.add(Integer.parseInt(editText2.getText().trim().toString()));
                        numbers.add(Integer.parseInt(editText3.getText().trim().toString()));
                        numbers.add(Integer.parseInt(editText4.getText().trim().toString()));
                        min.setText(String.valueOf(Collections.min(numbers)));}
                        });





                        share|improve this answer


























                          0














                          min.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                          List<Integer> numbers = new ArrayList<>();
                          numbers.add(Integer.parseInt(editText1.getText().trim().toString()));
                          numbers.add(Integer.parseInt(editText2.getText().trim().toString()));
                          numbers.add(Integer.parseInt(editText3.getText().trim().toString()));
                          numbers.add(Integer.parseInt(editText4.getText().trim().toString()));
                          min.setText(String.valueOf(Collections.min(numbers)));}
                          });





                          share|improve this answer
























                            0












                            0








                            0






                            min.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                            List<Integer> numbers = new ArrayList<>();
                            numbers.add(Integer.parseInt(editText1.getText().trim().toString()));
                            numbers.add(Integer.parseInt(editText2.getText().trim().toString()));
                            numbers.add(Integer.parseInt(editText3.getText().trim().toString()));
                            numbers.add(Integer.parseInt(editText4.getText().trim().toString()));
                            min.setText(String.valueOf(Collections.min(numbers)));}
                            });





                            share|improve this answer












                            min.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                            List<Integer> numbers = new ArrayList<>();
                            numbers.add(Integer.parseInt(editText1.getText().trim().toString()));
                            numbers.add(Integer.parseInt(editText2.getText().trim().toString()));
                            numbers.add(Integer.parseInt(editText3.getText().trim().toString()));
                            numbers.add(Integer.parseInt(editText4.getText().trim().toString()));
                            min.setText(String.valueOf(Collections.min(numbers)));}
                            });






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 13 '18 at 7:01









                            Dharm solanki

                            66




                            66






























                                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%2f53273358%2fhow-to-calculate-min-value-of-4-edittexts-in-android%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

                                Xamarin.iOS Cant Deploy on Iphone

                                Glorious Revolution

                                Dulmage-Mendelsohn matrix decomposition in Python