Examples of a method that requires a View
public void lista(View v) {
Toast.makeText(this, "Ok", Toast.LENGTH_SHORT).show();
}
public void botaoAbrir (View view) {
Intent i = new Intent(this, NovoRegistro.class);
startActivity(i);
}
I would like to call them within onCreate()
or some other method that does not require View
.
The way I tried and worked:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lista(new View(this));
}
But the question is, is that correct?
Can it be used like this without any problems? What other ways?
Is it advantageous for me to create a View
for the class, and always call it?