How To Get A Pop Up Layout? - android

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.

Related

How to display calculator inside dialog box

How to display calculator inside dialog box in android? I saw some examples but they add only view inside dialog box, but I want to add whole activity inside dialog.
You can put the following line inside your AndroidManifest, to make your activity like a dialog.
android:theme="#android:style/Theme.Dialog"

In Android How to Use Tab Layout in Alert Dialog Box?

In Android Application I want to Customize Alert Dialog Box shown below.Alert Dialog contain a Tab Layout With 3 Tabs.
Create a XML with the desired views (including the table) and call
View view = // instantiate it. Maybe with LayoutInflater(?)
new AlertDialog.Builder(myContext)
.setView(view);
.create();
Create a transparent Activity with Tab Layout..
Check this link for creating tab layout clickhere
Check this out for transparent activity clickhere

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();

android - dismiss spinner when user touches somewhere else

I have an app where the user presses a button and a custom spinner is popped so that the user can choose between nine colors. I want the spinner to be dismissed, when the user touches the background (every place on the sreen except from the spinner). Is this possible?
I tried to add an onTouchListener on the image that covers the background and call
dialog.dismiss();
but it does not work.
My spinner is custom Spinner, set in an xml file and popped with:
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.colorchooser);
Thank you in advance
First of all you should be able to add
dialog.setCanceledOnTouchOutside(true);
to accomplish what you want.
But the dismiss() method should also be working, I would guess that the place your are calling dialog.dismiss() is not reachable at the current moment.

display a view when an activity starts

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.

Categories

Resources