我尝试将此代码添加到书签Webview
Toast.makeText(getActivity().getApplicationContext(), "you don't have internet", Toast.LENGTH_SHORT).show();
还有这个
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
在这堂课上的书签
adapter = new SimpleAdapter(BookmarkActivity.this,
listRowData, R.layout.bookmark_list_row,
new String[]{TAG_TITLE, TAG_LINK},
new int[]{R.id.title, R.id.link});
listView.setAdapter(adapter);
答案 0 :(得分:0)
我解决了我的难题
new LoadBookmarks().execute();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if(!isNetworkAvailable()){
Toast.makeText(getApplicationContext(),"لا يوجد اتصال بالانترنت لتحميل الملف",Toast.LENGTH_SHORT).show();
}
else {
Object o = listView.getAdapter().getItem(position);
if (o instanceof Map) {
Map map = (Map) o;
Intent in = new Intent(BookmarkActivity.this, webview.class);
in.putExtra("url", String.valueOf(map.get(TAG_LINK)));
startActivity(in);
}
}
}
});