/Android_Random_Number_Generator_App

Basic App to Understand Random Generation and Setting Text on TextView

Primary LanguageJavaMIT LicenseMIT

Android_Random_Number_Generator_App

Basic App to Understand Random Generation and Setting Text on TextView

This topic is a part of My Complete Andorid Course

Code

1st Activity

        button = findViewById(R.id.button);
        fetchView = findViewById(R.id.fetchRange);
        putView = findViewById(R.id.putView);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Random rd = new Random();

                //fetch the range give by the user
                int range = Integer.parseInt(fetchView.getText().toString());

                //generate random number within range
                int rNumber = rd.nextInt(range);

                //put in putView
                putView.setText("Number is: " + rNumber);
            }
        });

App Highlight

Random Number Generator App Random Number Generator Code