Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old October 2nd, 2012, 03:41 PM   #1 (permalink)
Junior Member
Thread Author (OP)
 
olijf's Avatar
 
Join Date: Sep 2012
Location: Rotterdam, Holland
Gender: Male
Posts: 19
 
Device(s): Samsung Galaxy S3
Carrier: Not Provided

Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Skype™ to olijf dewitte.joost@gmail.com
Default textView as output

hello all,

i want to make a textView1 that displays my random generated number when clicked on button1. so that i can build 5 questions with the if element.
the main question is how do i get my random generated number in a textView?

I know there is a big chance the random number gen won't work but I am new in the Android scripting and want to discover new things, if you know how to get a random number gen please tell me. but don't put to much effort.

Code:
package EasyApp.randomquestion;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Button;



public class MainActivity extends Activity {

    TextView textView1;
    Button button1;
    
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    
    public final void RandomNumber (String args[], String RandomNumber){
        if (view == button1){
        RandomNumber =("random number:"+ 10 * Math.random());
        TextView text = (TextView) findViewById(R.id.textView1);
        text.setText(RandomNumber);
        }
    }

    

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
thanks in advance
- Olijf

Advertisements
olijf is offline  
Last edited by olijf; October 2nd, 2012 at 04:59 PM.
Reply With Quote
sponsored links
Old October 3rd, 2012, 03:52 AM   #2 (permalink)
Junior Member
 
Join Date: Aug 2012
Posts: 16
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 1 Time in 1 Post
Default

Hi Olijf,

You'll want to attach an OnClickListener to button1. Try to Google for "android button setonclicklistener tutorial". I'm sure you will find something useful.
chakdev is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:48 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.