我想创建一个类似于此图像对话框,谁能帮我出自定义对话框因为没有上网
-6
A
回答
1
您可以创建一个警告对话框来做到这一点。像这样的东西应该工作。
AlertDialog dialog = new AlertDialog.Builder(mContext)
.setTitle("Connection Failed")
.setMessage("Please Check Your Internet Connection")
.setPositiveButton("Try Again", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//Code for try again
}
})
.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}).create();
dialog.show();
0
0
第一你需要检查连接,为此添加下面的类。 类ConnectionDetector:
public class ConnectionDetector {
private Context _context;
public ConnectionDetector(Context context) {
this._context = context;
}
public boolean isConnectingToInternet() {
ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null)
for (int i = 0; i < info.length; i++)
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
return false;
}
}
然后检查ConnectionDetector的结果,并显示警告对话框。
相关问题
- 1. 自定义对话框没有标题
- 2. 自定义对话框来提醒网页没有加载
- 3. 自定义对话框
- 4. 自定义对话框Android
- 5. Android自定义对话框
- 6. android自定义对话框
- 7. iOS自定义对话框
- 8. 自定义onbeforeunload对话框
- 9. Wix自定义对话框
- 10. beforeunload自定义对话框
- 11. Android自定义对话框
- 12. 自定义对话框成为Android的
- 13. 自定义对话框为Android
- 14. 自定义对话框上的自定义键盘(Android)
- 15. Android - 从另一个自定义对话框显示自定义对话框
- 16. Android没有调整足够大的自定义对话框
- 17. 自定义对话框似乎没有设置宽度
- 18. 对话框自定义布局没有正确拉伸
- 19. 自定义IInternetSecurityManager没有与对话框调用
- 20. 如何添加seekbar到没有XML的自定义对话框
- 21. 自定义微调器对话框:对话框的popupbackground设置
- 22. 自定义下拉对话框(类似于保存对话框)
- 23. 取代facebook对话框中的自定义对话框在android
- 24. 没有定义UICollectionViewFlowLayout的行为,因为
- 25. Android:带有自定义对话框和中性按钮的警报对话框
- 26. 启动自定义对话框
- 27. FBConnect(IPHONE),自定义发布对话框
- 28. 从SettingsFragment打开自定义对话框
- 29. CSS自定义JQuery UI对话框
- 30. 对话框的Smalltalk自定义按钮
一切有关对话框(包括插图和代码):http://developer.android.com/intl/es/guide/topics/ui/dialogs.html#CustomLayout –