Saturday, June 4, 2011

Android Random Number Generation

Android Random Number Generation
DOWNLOAD SOURCE CODE

This for random number generation android .
                                    
source code

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btn=(Button)findViewById(R.id.btn);
        EditText edit=(EditText)findViewById(R.id.edit);
       
       
        btn.setOnClickListener(new OnClickListener() {
           
            public void onClick(View v) {
                // TODO Auto-generated method stub
               
                long tim = System.currentTimeMillis();
                Random random = new Random(tim);
                int RandomNumber = random.nextInt(100000);
                 EditText edit=(EditText)findViewById(R.id.edit);
                edit.setText(String.valueOf("xxx"+RandomNumber));
            }
        });
    }

No comments:

Post a Comment

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...