简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM