private void showDialog(String msg){
Builder builder =**new AlertDialog.Builder(HttpUtil.this);**
// AlertDialog.Builder builder =new Builder(HttpUtil.this);
builder.setMessage(msg)
.setCancelable(false)
.setPositiveButton("確定", new DialogInterface.OnClickListener(){
public void onClick (DialogInterface dialog,int id){
}
});
AlertDialog alert =builder.create();
alert.show();
}
加粗部分提示The constructor AlertDialog.Builder(HttpUtil) is undefined
new AlertDialog.Builder需要傳遞的參數是上下文,你的HttpUtil.this是什麼?如果HttpUtil.this是Activity,那麼改成new AlertDialog.Builder(((Activity)HttpUtil.this));或者 new AlertDialog.Builder(getActivity());