Issue
public void loadDialog() {
LayoutInflater inflater = LayoutInflater.from(this);
View subView = inflater.inflate(R.layout.dialogbox_delete_user_confirmation, null);
subView.findViewById(R.id.txtDeleteUser);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Fill your Secondary Details");
builder.setView(subView);
builder.create();
builder.show();
}
Here, I called the loadDialog()
function in onCreate()
method of the Activity
.But the AlertDialog
was not prompting when I load above particular Activity
.
Simply i created login
activity. After successful login
new activity will start. But at the same time, I want to show the Alert Dialog
box at while transaction of activities. How can I do that?
Solution
You can do so, by basically two simple ways. Which are:-
Using
BaseActivity
: In this case you need to create abase activity
that will have yourAlertDialog
with it'scontext
, (current yourdialog
is missing the context while transaction) whenever you want to show it you can show it by implementing the method after extending theBaseActivity
from any otherchild activities
. Steps are showing below :public class BaseActivity extends AppCompatActivity { public void showDialog(String msg) { // show the dialog } } public class Activity1 extends BaseActivity { public void someFunction() { showDialog("activity 1"); } } public class Activity2 extends BaseActivity { public void someFunction() { showDialog("activity 2"); } }
Using
Fragments
: In this you can control it from your respectiveactivity
orfragment
itself. But this is totally different approach from your current procedure.
Answered By - A S M Sayem
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.