我想在檢查互聯網的狀態後更改imageview圖像。 基本的,我想檢查互聯網是否工作,如果它我想要顯示某個圖像。檢查互聯網狀態後更改ImageView圖像
這裏我的代碼:
public void onClick(View v) {
// get Internet status
isInternetPresent = cd.isConnectingToInternet();
// check for Internet status
if (isInternetPresent) {
// Internet Connection is Present
// make HTTP requests
showAlertDialog(AndroidDetectInternetConnectionActivity.this, "Internet Connection", "You have internet connection", true);
} else {
// Internet connection is not present
// Ask user to connect to Internet
showAlertDialog(AndroidDetectInternetConnectionActivity.this, "No Internet Connection", "You don't have internet connection.", false);
}
}
好的,非常感謝。這真的有助於 – MoschDev
當放在創建代碼它給我一個錯誤的任務 – MoschDev
你得到什麼類型的錯誤?強迫關閉?還是其他什麼? –