Reputation: 155
I am doing an application in which a I want to implement a custom dialogn in the main activity. The thing is a want this dialog to be displayed once a day. How can I accomplished that ?
Upvotes: 0
Views: 285
Reputation: 1427
alert.xml in one TextView and Button in id
TextView id = alert_TV
Button id = alert_bnt
{
myDialog = new Dialog(this);
myDialog.setContentView(R.layout.alert);
myDialog.setTitle("name give ");
myDialog.setCancelable(true);
TextView alertTitle = (TextView) myDialog.findViewById(R.id.alert_TV);
alertTitle.setText("Date set");
Button set = (Button) myDialog.findViewById(R.id.alert_bnt);
.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
myDialog.dismiss();
}
});
myDialog.show();
}
Upvotes: 0
Reputation: 6092
For custom dialog http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application
And to open application once in a day you can use alarm manager which triggers on some specific time. If you want dialog box to open when user starts your app then you need to write some logic using shared preference.
Upvotes: 2