Twitter Facebook Delicious Digg Stumbleupon Favorites More

Saturday, 6 January 2018

RANDOM NUMBER GENERATOR CODE ANDROID



package com.example.viraj.diceapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import java.util.Random;

public class MainActivity extends AppCompatActivity {
    Button rollbutton;
    ImageView leftimage , rightimage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        rollbutton=(Button) findViewById(R.id.rollbutton);
        leftimage=(ImageView)findViewById(R.id.leftdice);
        rightimage=(ImageView)findViewById(R.id.rightdice);
        rollbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               // Toast.makeText(getApplicationContext(),"HELLO",Toast.LENGTH_LONG).show();
                Random random_nu_generator=new Random();
               int random= random_nu_generator.nextInt(1999);
                Toast.makeText(getApplicationContext(),"RANDOM NO IS = " + "" +random,Toast.LENGTH_LONG).show();

            }
        });
    }
}

Share:

0 comments:

Post a Comment

Blogger Tutorials

Blogger Templates

Sample Text

Copyright © ANDROID TUTORIAL CODE | Powered by Blogger
Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com & Distributed By Protemplateslab