วันจันทร์ที่ 1 เมษายน พ.ศ. 2556

Android Tabs

-->


Android Tabs

Scrollable Tabs

Scrolling tab controls can contain a larger number of items than a standard tab control. To navigate to the next/previous view, swipe left or right.



Fixed Tabs

Fixed tabs display all items concurrently. To navigate to a different view, touch the tab, or swipe left or right.
Fixed tabs are displayed with equal width, based on the width of the widest tab label. If there is insufficient room to display all tabs, the tab labels themselves will be scrollable. For this reason, fixed tabs are best suited for displaying 3 or fewer tabs.



Android Tabs Example Code


Java Code TabsExampleActivity.java


package com.example.tab;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;

public class MainActivity extends TabActivity implements TabHost.TabContentFactory {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //setContentView(R.layout.activity_tab);
            setContentView(R.layout.tabs_scroll);
                       
            final TabHost tabHost = getTabHost();
           
            LayoutInflater.from(this).inflate(R.layout.tabs1, tabHost.getTabContentView(), true);

        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("tab A", getResources().getDrawable(R.drawable.ic_launcher))
                .setContent(R.id.view1));
        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("tab B")
                .setContent(R.id.view2));
        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("tab C")
                .setContent(R.id.view3));
       
        for (int i=1; i <= 20; i++) {
            String name = "Tab " + i;
            tabHost.addTab(tabHost.newTabSpec(name)
                    .setIndicator(name)
                    .setContent(this));
        }
                       
      }
     
       /** {@inheritDoc} */
    public View createTabContent(String tag) {
       
      final TextView tv = new TextView(this);
        tv.setText("Content for tab with tag " + tag);
        return tv;
    }

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

tabs1.xml code


<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView android:id="@+id/view1"
            android:background="#3366FF"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="TAB A Blue Colour"/>

    <TextView android:id="@+id/view2"
            android:background="#FF3333"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="TAB B Red Colour"/>

    <TextView android:id="@+id/view3"
            android:background="#00AA00"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="TAB C Green Colour"/>

</FrameLayout>



tabs_scroll.xml code


<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="5dp">
        <HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </HorizontalScrollView>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>


DownLoad  Android Tabs Example Code





Android Control ควบคุมอุปกรณ์ต่างๆ ด้วย Android




สอนเขียน Android  สอนเขียนโปรแกรม Android แบบ Online

รับสอนเขียนโปรแกรม Android App สอนแบบ online สอนสด ตัวต่อตัว หรือ เป็นกลุ่ม ได้ทั่วประเทศ กำหนดเวลาเรียนได้
การเรียน Android App แบบ online สามารถกำหนดเวลาเรียน เองได้ ตามแต่ตกลงกัน
( รับสอน นอกสถานที่ แบบเป็น กลุ่ม ทั่วประเทศ )

แต่ละ Course ขึ้นอยู่กับพื้นฐานที่มี นะครับ

Course
1.JAVA Programming สำหรับผู้ที่ยังไม่มีพื้นฐานทางด้าน การเขียนโปรแกรม JAVA
เรียน 3-4 ครั้ง ครั้งละ 2 ชั่วโมง  

2.Beginning Android Development เริ่มต้นการพัฒนาด้วย Android ( ต้องมีพื้นฐาน JAVA แล้ว )
เรียน 5-6 ครั้ง ครั้งละ 2 ชั่วโมง 
เรียนจบคอร์สนี้ ก็สามารถทำ Application ได้แล้ว

3.Android Application สอนตามความต้องการในการเขียนโปรแกรม ใช้งานจริง เช่น โปรแกรมใช้งานด้านต่างๆ
ระยะเวลา และ ค่าเรียน ตามแต่ความยากง่ายของโปรแกรม ซึ่งอาจจะรวมสอน JAVA Programming ด้วยสำหรับผู้เริ่มต้นเลย
ดังนั้น ราคาสอน จะขึ้นอยู่กับ สเปคงาน

โปรแกรมที่ใช้ทำการเรียน Team Viewer  Version ล่าสุด Version 8
Meeting ID จะแจ้งให้ก่อนเรียน ผ่านทาง email sms Line หรือ อื่นๆ ตามสะดวก
ใช้ Tab Meeting ใส่ Meeting ID และใส่ชื่อ
แล้ว Join Meeting

ติดต่อ amphancm@gmail.com

วันพุธที่ 14 พฤศจิกายน พ.ศ. 2555

Android G Sensor

Android G Sensor

-->

Java Code SensorActivity.java

package android.example.sensor;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

public class SensorActivity extends Activity  implements SensorEventListener {

      private SensorManager sensorManager; // real device
    //private SensorManagerSimulator sensorManager; // SensorSimulator

      private Sensor accelerometer;
      private TextView txtAcc;
      private TextView txtX;
      private TextView txtY;
      private TextView txtZ;

      @Override
      public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
           
            sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); // Real device
            //sensorManager =  SensorManagerSimulator.getSystemService(this, SENSOR_SERVICE); // SensorSimulator
            accelerometer  = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
            //sensorManager.connectSimulator(); // SensorSimulator
            setContentView(R.layout.activity_sensor);
           
            txtAcc = (TextView) this.findViewById(R.id.txtAccuracy);
            txtX   = (TextView) this.findViewById(R.id.txtX);
            txtY   = (TextView) this.findViewById(R.id.txtY);
            txtZ   = (TextView) this.findViewById(R.id.txtZ);      
      }

    public void onAccuracyChanged(Sensor arg0, int arg1) {
            // Mudou a acurácia do sensor
            txtAcc.setText("= " + arg1);
    }

    public void onSensorChanged(SensorEvent event) {
            // Houve alguma aceleração no sensor
            // Normalmente, é preciso descontar a gravidade... Mas vamos deixar para depois
            txtX.setText("= " + event.values[0]);
            txtY.setText("= " + event.values[1]);
            txtZ.setText("= " + event.values[2]);
    }

    @Override
    protected void onPause() {
            // Vamos economizar baterias, pois a activity não está com o foco
            super.onPause();
            sensorManager.unregisterListener(this); // deixa de receber avisos
    }

    @Override
    protected void onResume() {
            // Temos que reiniciar o sensor
            super.onResume();
            sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
    }
     
}


activity_sensor.xml code

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:background="#55D5F5"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView 
        style="@style/titulo_link"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/rotulo1"
    />
<TextView
        style="@style/titulo_link.azul"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/txtAccuracy"
></TextView>

<TextView
        style="@style/titulo_link"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/acx"
    />
<TextView
        style="@style/titulo_link.verde"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/txtX"
></TextView>

<TextView
        style="@style/titulo_link"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/acy"
    />
<TextView
        style="@style/titulo_link.lilas"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/txtY"
></TextView>


<TextView
        style="@style/titulo_link"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/acz"
    />
<TextView
        style="@style/titulo_link.vermelho"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/txtZ"
></TextView>

</LinearLayout>



Download Android G Sensor Example Code



Android Control ควบคุมอุปกรณ์ต่างๆ ด้วย Android

สอนเขียน Android  สอนเขียนโปรแกรม Android
http://androidcontrol.blogspot.com/2012/01/beginning-android-training-android.html




สอนเขียน Android  สอนเขียนโปรแกรม Android แบบ Online

รับสอนเขียนโปรแกรม Android App สอนแบบ online สอนสด ตัวต่อตัว หรือ เป็นกลุ่ม ได้ทั่วประเทศ กำหนดเวลาเรียนได้
การเรียน Android App แบบ online สามารถกำหนดเวลาเรียน เองได้ ตามแต่ตกลงกัน
( รับสอน นอกสถานที่ แบบเป็น กลุ่ม ทั่วประเทศ )

แต่ละ Course ขึ้นอยู่กับพื้นฐานที่มี นะครับ

Course
1.JAVA Programming สำหรับผู้ที่ยังไม่มีพื้นฐานทางด้าน การเขียนโปรแกรม JAVA
เรียน 3-4 ครั้ง ครั้งละ 2 ชั่วโมง  

2.Beginning Android Development เริ่มต้นการพัฒนาด้วย Android ( ต้องมีพื้นฐาน JAVA แล้ว )
เรียน 5-6 ครั้ง ครั้งละ 2 ชั่วโมง 
เรียนจบคอร์สนี้ ก็สามารถทำ Application ได้แล้ว

3.Android Application สอนตามความต้องการในการเขียนโปรแกรม ใช้งานจริง เช่น โปรแกรมใช้งานด้านต่างๆ
ระยะเวลา และ ค่าเรียน ตามแต่ความยากง่ายของโปรแกรม ซึ่งอาจจะรวมสอน JAVA Programming ด้วยสำหรับผู้เริ่มต้นเลย
ดังนั้น ราคาสอน จะขึ้นอยู่กับ สเปคงาน

โปรแกรมที่ใช้ทำการเรียน Team Viewer  Version ล่าสุด Version 8
Meeting ID จะแจ้งให้ก่อนเรียน ผ่านทาง email sms Line หรือ อื่นๆ ตามสะดวก
ใช้ Tab Meeting ใส่ Meeting ID และใส่ชื่อ
แล้ว Join Meeting

ติดต่อ amphancm@gmail.com