display a view when an activity starts - android

I need to display a certain view when an activity starts, and when the user click ckecked to dismiss the view. It look like this
:
Has anyone an idea how can I do this? Any idea is welcome.

Yes, you can use a custom dialog
just create a custom XML and inflate it into your dialog object
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
and then dismiss it by calling dialog.dismiss();

create custom dialog using below link and open it when activity starts...
you need to increase the margin to proivde more spaces
Have a look at custom dialog examples -
custom dialog 1
custom dialog 2

yes, you can use PopupWindow for Creating window
see these tutorila for adding PopupWindow in your Activity:
Using the PopupWindow class in Android apps
Example of using PopupWindow

You could use a RelativeLayout for this. When the user clicks check, the visibility of the 'upper' layout must be set to GONE.

Related

How to bypass android dialog outside click

What I want to do is to show the dialog message but make it still possible to click on the items behind. On any click, the dialog would dismiss
Right now I need to click once to dismiss the dialog and a second time to click on a field.
It is something possible ? Or is there an alternative to using Dialogs?
Edit: Solution found by adding Layout Flags to the window.
In kotlin:
dialog.window?.setLayout(ConstraintLayout.LayoutParams.FLAG_NOT_FOCUSABLE, ConstraintLayout.LayoutParams.FLAG_NOT_FOCUSABLE)
By using Dialog you cannot achieve what you are looking for. instead of using Dialog USE FRAGMENT.
The examples are given in official documentation here.
You Can define a full layout in the background of the dialog and set onClick listener to that layout

Handling textview hit bottom in alert dialog

I'm setting a message in a simple alert dialog. I need to know if the user has read all the text inside the dialog or not. Is there any way to set a scroll listener or something in an alert dialog?
Create your custom dialog and then set some listener to your custom View. Here's a good example: http://www.mkyong.com/android/android-custom-dialog-example/
and
https://stackoverflow.com/a/10713501

How to create a PopupWindow with images?

I'm trying to create a popup window similar to programmatically. Unfortunately I couldn't figure out any helpful resource so far for creating a similar popup.
You can do it with Dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.chat_custom_dialog);
dialog.setTitle("custom dialog");
dialog.show();
where dialog.setContentView(R.layout.chat_custom_dialog); will set the layout of the dialog.
And if you want to update the dialog's layout views you can call the dialog.findViewById(id) to get the view inside of the layout same as what you are doing in the activity

How to display customized alert dialog within multiple tab widgets in android?

I have to create customized alert in my android application. And this is my page
I have created 4 main tabs and two subtabs within my tab widget. pnr status is my first tab first page. Within that i have created customized list view. When i clicked my list view I have to show my customized alert view . I can create my customized alert. My code is here. http://pastie.org/8366400
Now my issue is When i click the list view content it shows some error my errors are http://pastie.org/8366406.
My launcher activty have four tabs. which means main actiivty. Then my first tab content is pnr status and schedule . So my pnr status will be shown first when i opened my application. But I tired some other way and found some thing. When i give my pnrstatus activity as launcher activty means my coustomized alert would shown. In the means time when i give my maintab actiivty as launcher it won't come. Now my question is If we are using tabwidget within tabwidget means our is alert won't come? Can any body help me to resolve this issue?
Use getParent() instead of context
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getParent());
refer Android dialogs are causing android.view.WindowManager$BadTokenException: Unable to add window
Try this, You can create your own xml file. setContentView this method you can set your customview.
final Dialog dialog = new Dialog(YourActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Add your lyout
dialog.setContentView(R.layout.Yourlayout);
dialog.setCancelable(true);
// Declare your view here
// Do your stuff here
dialog.show();

How To Get A Pop Up Layout?

How can I have a pop-up window, with a new layout, but with the old layout in the background?
Also I'd like to have a button on the first layout call the second layout based on an if-statement, using something like this
"if Button has a background, button open new layout, if not null"
You could use a Dialog to create the pop-up. For example, in your activity onCreate() method set up a new dialog and specify the layout using XML like normal.
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.--);
then simply call dialog.show() when you want to show the pop-up.

Categories

Resources