olijf
Newbie
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.
thanks in advance
- Olijf
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;
}
}
- Olijf