I am doing a project Android to recreate an application similar to Simon,
I created all the buttons, and thanks to the toast, I can see what they do. my problem is that I cannot generate a random number to the button to start *
I tried to use a random number generator that I found on the internet. but I can not figure out if it works or not because it gives me an error "public final class" saying it can not find it. I tried to create the class file R. but not resolved.
Can anyone help me please?
thx
package com.simonsays;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnStart= (Button)findViewById(R.id.status);
btnStart.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO genero casualmente il numero. Salvo il colore scelto corrente
Toast.makeText(MainActivity.this, "sono in start click", Toast.LENGTH_LONG).show();
}
});
Button btnStart1= (Button)findViewById(R.id.green);
btnStart1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO genero casualmente il numero. Salvo il colore scelto corrente
Toast.makeText(MainActivity.this, "sono in green click", Toast.LENGTH_SHORT).show();
}
});
Button btnStart2= (Button)findViewById(R.id.red);
btnStart2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO genero casualmente il numero. Salvo il colore scelto corrente
Toast.makeText(MainActivity.this, "sono in red click", Toast.LENGTH_SHORT).show();
}
});
Button btnStart3= (Button)findViewById(R.id.blue);
btnStart3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO genero casualmente il numero. Salvo il colore scelto corrente
Toast.makeText(MainActivity.this, "sono in blue click", Toast.LENGTH_SHORT).show();
}
});
Button btnStart4= (Button)findViewById(R.id.yellow);
btnStart4.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Toast.makeText(MainActivity.this, "sono in yellow click", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}