我有这个错误: 错误:(55,13)错误:非法字符:' \ u0650' 错误:任务':app:compileDebugJavaWithJavac'。>执行失败编译失败;请参阅编译器错误输出以获取详细信 我试图在我的应用程序中重试按钮 这是我的代码
private void CallNetwork(String baseUrl) {
if (NetworkUtils.isNetworkAvailable(getActivity())) {
new Url_cont(this, getActivity()).execute(baseUrl);
} else {
ِAlertDialog.Builder alert= new AlertDialog.Builder(getActivity());
alert.setTitle("Error !!!");
alert.setMessage("sorry there is no connection please check your internet and retry");
AlertDialog alertDialog =alert.create();
alert.setPositiveButton("Retry",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which){
dialog.dismiss();
CallNetwork(MovieUrl);
}
});
alertDialog.show();
Toast.makeText(getActivity(),"network unavailble!!!",Toast.LENGTH_LONG).show();
}
}
我的设备是google nexus 7 api 23
中的错误 ِAlertDialog.Builder alert= new AlertDialog.Builder(getActivity());
我需要解决这个问题的方法
答案 0 :(得分:0)
我现在终于回答了
{
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setCancelable(false);
builder.setTitle("No Internet");
builder.setMessage("Internet is required. Please Retry.");
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
System.exit(0);
}
});
builder.setPositiveButton("Retry", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
CallNetwork(MovieUrl);
}
});
AlertDialog dialog = builder.create();
dialog.show();
Toast.makeText(getActivity(), "Network Unavailable!", Toast.LENGTH_LONG).show();
}
这段代码更好而且效果很好所以如果你想重试按钮只是使用这段代码,这个错误会再次出现