By admin, 12 二月, 2015

<style>
::-webkit-input-placeholder { /* WebKit browsers */
    color:    #909;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
   color:    #909;
   opacity:  1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
   color:    #909;
   opacity:  1;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
   color:    #909;
}
</style>

标签

By admin, 12 二月, 2015

<style>
.noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
</style>

<p>
  Selectable text.
</p>
<p class="noselect">
  Unselectable text.
</p>

标签

By admin, 10 二月, 2015

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();

标签

By admin, 10 二月, 2015

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" />

标签

By admin, 10 二月, 2015

AndroidManifest.xml的activity里添加android:screenOrientation="portrait"

<activity android:name=".SomeActivity" android:label="@string/app_name" android:screenOrientation="portrait">

标签