2013年10月3日 星期四

Youtube music channel

https://www.youtube.com/user/goldddiggaa


Android Tab View

[Android] 建立Tab View的三種方式(上)

第一種,將每個tab的內容寫在同個Activity

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:orientation="vertical" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
            </FrameLayout>
            
        </LinearLayout>
    </TabHost>

</LinearLayout>


public class MainActivity extends TabActivity implements TabContentFactory {


  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TabHost mTabHost = getTabHost();    
        mTabHost.clearAllTabs();

        mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("TAB1").setContent(this));

        mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("TAB2").setContent(this));
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    //getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

  @Override
  public View createTabContent(String tag) {
    TextView textView = new TextView(this);
    textView.setText("I'm " + tag);
    return textView;

  }

}


第二種,不同tab的內容分別寫在不同的Activity
mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("TAB2").setContent(this));
的setContent帶入參數intent即可!

行動是唯一答案

“You may never know what results come of your action, but if you do nothing there will be no result.”
– Mahatma Gandhi, Statesman
「你可能永遠不知道你的行為能帶來什麼結果,但沒有行動就不會有結果。」– 甘地 (政治家)

增加Android emulator速度

ADT中通过Android SDK Manager安装Intel Hardware Accelerated Execution Manager

1. Android SDK Manager安裝 Intel x86 Emulator Accelerator (HAXM)
  基本上 沒安裝的都把他裝一裝

2. 測試 打開CMD
輸入sc query intelhaxm 
如果是以下結果
[SC] EnumQueryServicesStatus:OpenService FAILED 1060:
The specified service does not exist as an installed service.

去對應的sdk\extras\intel\Hardware_Accelerated_Execution_Manager 路徑下
安裝...\sdk\extras\intel\Hardware_Accelerated_Execution_Manager\IntelHaxm.exe

3.打開CMD
輸入sc query intelhaxm 
如果出現
SERVICE_NAME: intelhaxm
        TYPE               : 1  KERNEL_DRIVER
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0

        WAIT_HINT          : 0x0

表示成功

4.打開Android Virtual Device Manager
去Edit你的Device
CPU/ABI選項可以選擇了

選一個CPU吧,我個人覺得效果不大 =)

2013年10月2日 星期三