0
私はダイアログメッセージを表示するために使用する単純なクラスがあります。アンドロイド - ショーダイアログ静的クラスから
public class Utils {
static void ShowMessage(Context c, String DialogTitle, String MessageToDisplay, int LayoutResourceID, int ImageResourceID){
//Create new dialog.
Dialog dialog = new Dialog(c);
//Set the view to an existing xml layout.
dialog.setContentView(LayoutResourceID);
dialog.setTitle(DialogTitle);
//Set textbox text and icon for dialog.
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText(MessageToDisplay);
ImageView image = (ImageView)dialog.findViewById(R.id.image);
image.setImageResource(ImageResourceID);
//Show the dialog window.
dialog.show();
}
}
をそして、私はのOnClickListenerのイベント内で、私の活動からそれを呼び出すようにしようとしています
private OnClickListener btnSubmitIssueClick = new OnClickListener(){
public void onClick(View v){
//Check for valid Summary & Description.
if(mSummaryEditText.getText().toString().trim().length() == 0){
Utils.ShowMessage(getBaseContext(), "Submit Issue Error", getBaseContext().getString(R.string.ERROR_SummaryRequired),
R.layout.modal_dialog, R.drawable.warning);
return;
}else if(mDescriptionEditText.getText().toString().trim().length() == 0){
Utils.ShowMessage(getBaseContext(), "Submit Issue Error", getBaseContext().getString(R.string.ERROR_DescriptionRequired),
R.layout.modal_dialog, R.drawable.warning);
return;
}
}
};
しかし、私はそれを実行したとき、私はこのエラーを取得:
03-07 16:56:00.290: W/WindowManager(169): Attempted to add window with non-application token WindowToken{4162e780 token=null}. Aborting.
任意のアイデア私が何をするようになどのボタン、間違っている?
このリンクをありがとうございました...私はいつも "getContext"メソッドのタイプを区別するのが困難でした。 – Robert