Android App Privacy Policy
Information that may be collected from you
When you use this app, you do not need to enter your personal information (such as your name, ID number, email address, etc.). You will not acquire your personal information without your knowledge, unless you know in advance.
Third-party website
This service may include links to third party services or other third party websites that include the retailer with whom you deal. Please note that this policy applies only to personal information we collect through our services and we are not responsible for the personal information that third parties may collect, store and use through their websites or services. You should always read through the privacy policies of every web site you visit.
This policy change
We may from time to time make changes to this policy for a variety of reasons, for example, to reflect changes in laws and regulations or changes in industry specifications and technology.
If you have any questions or comments about this policy, please contact us.
Android App 隱私權政策
可能向您收集之資訊
您使用此APP時,並不需要輸入個人資料 (例如姓名、身分證字號、電子郵件地址等 ) ,除非事先告知,此APP不會在您不知情的狀況下,取得您個人資料。
第三方網站
本服務可能包含連至第三方服務或第三方其他網站之連結,這個第三方包括與您進行交易的零售商。請注意,本政策僅適用於我方透過服務收集的個人資訊,我方不對第三方可能透過其網站或服務收集、存儲及使用的個人資訊負有責任。您應始終仔細閱讀每個您瀏覽網站的隱私權政策。
本政策的變更
我方可能因各種原因而需不時對本政策進行變更,例如,為了反應法律與法規的變更或行業規範與技術發展的改變。
如果您對本政策有任何問題或意見,請聯絡我們。
2017年12月17日
2017年12月14日
Android ToolBar
Android ToolBar
ToolBar是在安卓5.0中引入的(android.widget.Toolbar)。在不引入兼容庫的情况下,只能在5.0以上的版本運行;而在引用android.support.v7.widget.Toolbar類之後,可以支持安卓2.1以上版本。
引入了android.support.v7兼容庫。
//build.gradle
compile 'com.android.support:appcompat-v7:25.3.0'
然後更改Application的主题,找到values文件夾下的styles.xml,更改主题為NoActionBar
<!--AndroidManifest.xml-->
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme
<!--修改AppTheme的定义-->
>
<!--styles.xml-->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Layout布置
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="me.zxm.learnactionbartoolbar.MainActivity"
>
<android.support.v7.widget.Toolbar
android:id="@+id/ToolBar"
android:minHeight="?attr/actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleTextColor="@android:color/white"
android:background="?attr/colorPrimary"
></android.support.v7.widget.Toolbar>
</RelativeLayout>
在res文件夾下新建menu文件夾,然後在该文件夾下新增一个布局文件
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/mySearch"
android:icon="@android:drawable/ic_menu_search"
app:showAsAction="ifRoom"
android:title="Search">
</item>
<item
android:id="@+id/myMore"
android:icon="@android:drawable/ic_menu_more"
app:showAsAction="ifRoom|withText"
android:title="More">
</item>
</menu>
Activity Toolbar Code
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
public class MainActivity extends AppCompatActivity implements Toolbar.OnMenuItemClickListener{
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.ToolBar);
toolbar.setNavigationIcon(R.mipmap.ic_launcher);
toolbar.setLogo(R.mipmap.ic_launcher);
toolbar.setTitle("ToolBar");
toolbar.setSubtitle("toolbar");
setSupportActionBar(toolbar);
toolbar.setOnMenuItemClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu,toolbar.getMenu());
return true;
}
}
顯示Back圖示
toolbar = (Toolbar) findViewById(R.id.hack_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//do something you want
}
});
ToolBar是在安卓5.0中引入的(android.widget.Toolbar)。在不引入兼容庫的情况下,只能在5.0以上的版本運行;而在引用android.support.v7.widget.Toolbar類之後,可以支持安卓2.1以上版本。
引入了android.support.v7兼容庫。
//build.gradle
compile 'com.android.support:appcompat-v7:25.3.0'
然後更改Application的主题,找到values文件夾下的styles.xml,更改主题為NoActionBar
<!--AndroidManifest.xml-->
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme
<!--修改AppTheme的定义-->
>
<!--styles.xml-->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Layout布置
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="me.zxm.learnactionbartoolbar.MainActivity"
>
<android.support.v7.widget.Toolbar
android:id="@+id/ToolBar"
android:minHeight="?attr/actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleTextColor="@android:color/white"
android:background="?attr/colorPrimary"
></android.support.v7.widget.Toolbar>
</RelativeLayout>
在res文件夾下新建menu文件夾,然後在该文件夾下新增一个布局文件
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/mySearch"
android:icon="@android:drawable/ic_menu_search"
app:showAsAction="ifRoom"
android:title="Search">
</item>
<item
android:id="@+id/myMore"
android:icon="@android:drawable/ic_menu_more"
app:showAsAction="ifRoom|withText"
android:title="More">
</item>
</menu>
Activity Toolbar Code
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
public class MainActivity extends AppCompatActivity implements Toolbar.OnMenuItemClickListener{
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.ToolBar);
toolbar.setNavigationIcon(R.mipmap.ic_launcher);
toolbar.setLogo(R.mipmap.ic_launcher);
toolbar.setTitle("ToolBar");
toolbar.setSubtitle("toolbar");
setSupportActionBar(toolbar);
toolbar.setOnMenuItemClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu,toolbar.getMenu());
return true;
}
}
顯示Back圖示
toolbar = (Toolbar) findViewById(R.id.hack_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//do something you want
}
});
2017年9月24日
ViewTreeObserver
ViewTreeObserver
ViewTreeObserver vto =textViewLeft.getViewTreeObserver();vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT < 16) { textViewLeft.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { textViewLeft.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }});
2017年8月1日
android E/eglCodecCommon 錯誤處理方式
android E/eglCodecCommon 錯誤處理方式
android studio 模擬器 api 22
錯誤訊息,重複出現
E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,73)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
處理方式
You can solve this by adding android:hardwareAccelerated="false" in AndroidManifest.xml
android studio 模擬器 api 22
錯誤訊息,重複出現
E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,73)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
處理方式
You can solve this by adding android:hardwareAccelerated="false" in AndroidManifest.xml
2017年5月8日
Android Dialog 標題換行
Android Dialog 標題換行
TextView view = new TextView(this);view.setText(appraisal.getTitle() + "\n" + appraisal.getNoticeInfo());view.setPadding(40, 20, 0, 20);view.setTextSize(12); Dialog alertDialog = new AlertDialog.Builder(this).setCustomTitle(view);
2017年3月11日
Android 判斷手機或是平板
Android 判斷手機或是平板
public static boolean isPad(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
回傳true就是平板
回傳false就是手機
public static boolean isPad(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
回傳true就是平板
回傳false就是手機
2017年2月20日
單例模式 Singleton
單例模式 Singleton
保證一個類別只有一個物件,而且要提供存取該物件的統一方法
public class FragmentOne extends Fragment {
private static FragmentOne fragmentOne = null;
private Singleton(){
// 建立物件
}
public static FragmentOne getInstance() {
if (fragmentOne == null) {
// 多執行緒時,當物件需要被建立時才使用synchronized保證fragmentOne一定是單一的 ,增加程式校能
synchronized(FragmentOne.class){
if (fragmentOne == null) {
// 第一次被呼叫的時候再建立物件
fragmentOne = new FragmentOne();
}
}
return fragmentOne;
}
}
補充
package com.test;
public class TestSingletionPattern {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
class Singleton {
private static final Singleton singleton = new Singleton();
private Singleton() {
}
public static Singleton getInstance() {
return singleton;
}
public static void doSomething() {
}
}
class SingletonB {
private static SingletonB singleton = new SingletonB();
private SingletonB() {
}
// 多執行緒時使用synchronized保證Singleton一定是單一的
public static synchronized SingletonB getInstance() {
if (singleton == null) {
singleton = new SingletonB();
}
return singleton;
}
public static void doSomething() {
}
}
class SingletonC {
private static SingletonC singleton = new SingletonC();
private SingletonC() {
}
// 多執行緒時,當物件需要被建立時才使用synchronized保證Singleton一定是單一的 ,增加程式校能
public static SingletonC getInstance() {
if (singleton == null) {
synchronized (SingletonC.class) {
if (singleton == null) {
singleton = new SingletonC();
}
}
}
return singleton;
}
public static void doSomething() {
}
}
保證一個類別只有一個物件,而且要提供存取該物件的統一方法
public class FragmentOne extends Fragment {
private static FragmentOne fragmentOne = null;
private Singleton(){
// 建立物件
}
public static FragmentOne getInstance() {
if (fragmentOne == null) {
// 多執行緒時,當物件需要被建立時才使用synchronized保證fragmentOne一定是單一的 ,增加程式校能
synchronized(FragmentOne.class){
if (fragmentOne == null) {
// 第一次被呼叫的時候再建立物件
fragmentOne = new FragmentOne();
}
}
return fragmentOne;
}
}
補充
package com.test;
public class TestSingletionPattern {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
class Singleton {
private static final Singleton singleton = new Singleton();
private Singleton() {
}
public static Singleton getInstance() {
return singleton;
}
public static void doSomething() {
}
}
class SingletonB {
private static SingletonB singleton = new SingletonB();
private SingletonB() {
}
// 多執行緒時使用synchronized保證Singleton一定是單一的
public static synchronized SingletonB getInstance() {
if (singleton == null) {
singleton = new SingletonB();
}
return singleton;
}
public static void doSomething() {
}
}
class SingletonC {
private static SingletonC singleton = new SingletonC();
private SingletonC() {
}
// 多執行緒時,當物件需要被建立時才使用synchronized保證Singleton一定是單一的 ,增加程式校能
public static SingletonC getInstance() {
if (singleton == null) {
synchronized (SingletonC.class) {
if (singleton == null) {
singleton = new SingletonC();
}
}
}
return singleton;
}
public static void doSomething() {
}
}
2017年1月7日
Android get StatusBar Height and ActionBar Height
//取得狀態列高度
int statusBarHeight = 0; int resource = this.getResources().getIdentifier("status_bar_height",
"dimen", "android"); if (resource > 0) { statusBarHeight = this.getResources().getDimensionPixelSize(resource); }
//取得標題列高度
int actionBarHeight=0; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
getResources().getDisplayMetrics()); }
//應用區域高度
Rect outRect1 = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect1);
//VIEW繪製區域高度
Rect outRect2 = new Rect();
getWindow().findViewById(Window.ID_ANDROID_CONTENT).getDrawingRect(outRect2);
訂閱:
文章 (Atom)