$avg = array_sum($a) / count($a);
通常,我们还需要把多余的小数去掉:
$avg2 = round($avg, 1);
$avg = array_sum($a) / count($a);
通常,我们还需要把多余的小数去掉:
$avg2 = round($avg, 1);
SharedPreferences prefs = this.getSharedPreferences(
"com.example.app", Context.MODE_PRIVATE);
读取设置:
String dateTimeKey = "com.example.app.datetime";
// use a default value using new Date()
long l = prefs.getLong(dateTimeKey, new Date().getTime());
编辑保存设置:
Date dt = getSomeDate();
prefs.edit().putLong(dateTimeKey, dt.getTime()).apply();
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));
public boolean isOnline() {
ConnectivityManager cm =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnectedOrConnecting();
}
在AndroidManifest.xml中添加下面权限:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Calendar c = Calendar.getInstance();
int seconds = c.get(Calendar.SECOND);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
在
AndroidManifest.xml的activity里添加android:screenOrientation="portrait"
<activity android:name=".SomeActivity" android:label="@string/app_name" android:screenOrientation="portrait">
一样的。历史问题,API 8+用match_parent就可以了
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/**yourtextstring**"
/>
CTRL+F12
最新评论