1
I’m developing an app in which you will have the first Activity
greeting, and I want to show it only once, only when the app first opens.
In this case, I created a Activity
calling a layout containing the textview and button, as soon as the user clicks on the button, will open the Activity
main app, and then do not want to Activity
greeting be shown more.
My layout (summarized):
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Saudação Aqui" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="sendMessage"
android:text="Ok, entrar para Activity principal e não mostrar mais essa tela" />
Greeting activity:
Button button;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=(Button)findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(getApplicationContext(),Activity Principal.class);
startActivity(i);
}
});
}
Thank you very much!
I don’t understand your doubt!! You have already implemented something to save on Sharedpreferences ?
– Thiago Luiz Domacoski
You can find something similar here in this answer.
– Paulo Rodrigues
@Thiagoluizdomacoski It is that I am beginner friend, I am right at the beginning of the programming world. What I wanted to manipulate, was this Activity (greeting) to show only once. I don’t know exactly how to "mount" (implement) with sharedpreferences. In this case, you could give me an example of how to do this manipulation?
– Tech Positivo
@Paulorodrigues Ok friend, thank you very much. I will take a look ;)
– Tech Positivo