Starting Dialog from QuickAction Button

好久不见. 提交于 2019-12-12 04:58:45

问题


I have an app with a quickaction shown once a button is pressed. The quickaction shows a popup like in the Gallery 3D application for android, and when an action is clicked, I try to show a dialog, but I recieve a force close. Debug in Eclipse points to the slideDialog.show(); line, but I need that to show the dialog, right? Here's an example of one of those quickaction/dialogs.

final ActionItem third = new ActionItem();

third.setTitle("Adjust Brush Width");

third.setIcon(getResources().getDrawable(R.drawable.arrow_up));

 third.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

slideDialog = new slideDialog(getApplicationContext());

   slideDialog.show();

slideDialog.setOnDismissListener(new OnDismissListener() {

 @Override

 public void onDismiss(DialogInterface dialog) {

  mPaint.setStrokeWidth(slideDialog.getSize());
 }
      });    }   });

回答1:


I have a sneaky suspicion that getApplicationContext() is not returning the right Context for your need.... have you tried passing in Classname.this into slideDialog... i.e. sildeDialog = new slideDialog(Classname.this) where Classname is the name of the class that you're currently writing in?



来源:https://stackoverflow.com/questions/4708098/starting-dialog-from-quickaction-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!