I'm new to android and Java. I want to make an onClick method which carries an int argument, so this is my attempt:
public void randomClick(final int randomIndex)
{
private OnClickListener top_listener = new OnClickListener() {
public void onClick(View v) {
Intent top = new Intent(Main.this, ProjectDetail.class);
top.putExtra("spendino.de.ProjectDetail.position", randomIndex);
startActivity(top);
}
};
}
but it still contains error, can anybody fix that for me?
Later I want set the method to an ImageView, it will look more or less like this image1.randomClick(randomIndex1);
.