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