android 检查网络连接 &simpleadapter

//检查网络
public boolean netconn() {
ConnectivityManager con = (ConnectivityManager)
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkinfo = con.getActiveNetworkInfo();
if (networkinfo == null || !networkinfo.isAvailable()) {
Toast.makeText(context.getApplicationContext(), "网络异常",
Toast.LENGTH_SHORT).show();
return false;
}
boolean wifi = con.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
.isConnectedOrConnecting();
if (!wifi) {
Toast.makeText(context.getApplicationContext(), "可以用wifi",
Toast.LENGTH_SHORT).show();
}
return true;

}

//SimpleAdapter 
SimpleAdapter adapter = new SimpleAdapter(this, data ,
R.layout.simple, new String[] { "title", "img" }, new int[] {
R.id.title, R.id.img });
setListAdapter(adapter);

你可能感兴趣的:(SimpleAdapter)