Archive for December 2015
Text Field
°°°°°°°°°°
ဒီအခန္းအတြက္ project အသစ္ေဆာက္လိုက္ပါ။
အရင္အတိုင္းပဲ LinearLayout မွာ android:orientation ကို vertical မထားပဲ horizontal ထားလိုက္ပါ။ အဲ့့ေၾကာင္းကို ေနာက္ပိုင္းမွ ေဖာ္ျပေပးပါမယ္။ ဒီအခန္းက Email တို႔ passwordတို႔ ရိုက္တဲ့ box ေလးအေၾကာင္း ပါ။
ပထမဆံုးtutorialမွာလို android:textကို Massage လို႔နာမည္ေပးလိုက္ပါ။ <TextView......../>ရဲ႕ ေနာက္ ကေန ႏွစ္ေၾကာင္းေလာက္ ဆင္းလိုက္ပါ။ ၿပီးရင္ေအာက္ က codeေလးေတြကို ထည့္ၾကည့္ပါ။
<EditText
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
TextSize ကေသးေနတယ္ဗ်။ ဟိုးအရင္က tutorial ထဲကလို TextSize ျပင္ၾကည့္ဗ်ာ။ Size က 20sp ေလာက္ထားရင္ အိုေကတယ္။ အရင္သင္ခန္းစာေတြ ေက်ညက္ခဲ့ရင္ ျပန္ၾကည့္စရာ မလိုဘူးေပါ့ဗ်ာ။ ၿပီးရင္ run ၾကည့္ပါ။
ဂလိုေလးေပါ့။
Password ထည့္တဲ့ Text Fieldလုပ္မယ္ဗ်ာ။ အေပၚက android:text က Massage ေနရာမွာ password လို႔ ေျပာင္းလိုက္ပါ။ Edit text ကိုပဲ password လုပ္ လို႔ရတယ္ေနာ္ ဒါေပမယ့္ password႐ိုက္လိုက္ရင္ စာလံုး ေတြကေပၚေနမွာေပါ့။ password လို ႐ိုက္ၿပီးခဏ ေနတာနဲ႔ အစက္ေလးေတြျဖစ္ေအာင္ လုပ္မယ္ေနာ္။ ေစာ ေစာကထည့္ထားတဲ့
<EditText ေနာက္ကေန တစ္ေၾကာင္းဆင္းလိုက္ပါ။ ၿပီးရင္ android:inputType="textPassword" လို႔ထည့္ပါ။
code အျပည့္အစံုက ဒီလိုေနာ္။
<EditText
android:inputType="textPassword"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
ဒီလိုအစက္ေလးေတြျဖစ္သြားတာေပါ့။
ေနာက္ထပ္ စာလံုးpassword ၿပီးရင္ ဂဏန္းpassword လုပ္ၾကည့္မယ္ေနာ္။ ေစာေစာကထည့္ထားတဲ့ android:inputType ကိုဖ်က္ၿပီး android:inputType="numberPassword" လို႔အစားထိုး လိုက္ပါ။ အျပည့္အစံုက ဒီလိုေလးေနာ္။
<EditText android:inputType="numberPassword"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
ၿပီးရင္ Run ၾကည့္လိုက္ပါ။
ဒီလိုေလးေနာ္။
ဒီတစ္ခါ Email ထည့္တဲ့ Box ေလးလုပ္မယ္ေနာ္။ အ ေပၚကအတိုင္းပဲ android:text မွာ Password ေနရာမွာ Email အစားထိုးလိုက္ပါ။ ၿပီးေတာ့ android:inputType ကိုဖ်က္ၿပီး android:inputType="textEmailAddress" လို႔အစားထိုး လိုက္ပါ။ အျပည့္အစံုက ဒီလိုေနာ္။
<EditText
android:inputType="textEmailAddress"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
ၿပီးရင္ Run ၿပီး စာလံုးေလးေတြ ႐ိုက္ထည့္ၾကည့္ပါ။
Keyboard မွာ @ နဲ႔ .com ခုပ္ေလးပါလာပါလိမ့္မယ္။
ဒီတစ္ခါ နာမည္ေရးဖို႔ box ေလးေရးမယ္ေနာ္။ အ ေပၚကအတိုင္းပဲ android:text မွာ Email ေနရာမွာ Name အစားထိုးလိုက္ပါ။ ၿပီးေတာ့ android:inputType ကိုဖ်က္ၿပီး android:inputType="textPersonName" လို႔အစားထိုး လိုက္ပါ။ အျပည့္အစံုက ဒီလိုေလးေနာ္။
<EditText
android:inputType="textPersonName"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
run ၾကည့္လိုက္ေနာ္။
ဒီလိုေလးေနာ္။
ေနာက္တစ္ခါ ဖုန္းနံပါတ္ ထည့္တဲ့ box ေလးလုပ္မယ္။ အေပၚမွာ အမ်ားႀကီးလုပ္ၿပီးၿပီဆိုေတာ့ မွတ္မိေနေလာက္ ပါၿပီ။ ေနာက္မွာလဲ က်န္ေသးေတာ့ အတိုေကာက္ပဲ ေျပာၾကမယ္။ text နဲ႔ input လို႔ပဲ ေျပာေတာ့မယ္။ ရလားမသိဘူး။ ရရမရရ လုပ္ၿပီ။ text မွာ Phone ထည့္ inputမွာ android:inputType="phone" လို႔ေျပာင္ းၿပီး Run မယ္ဗ်ာ။
ဂဏန္းေလးေတြပဲေပါ့။
ဒါကေတာ့ အခ်ိန္ထည့္တဲ့ box ေပါ့။ text မွာ Time| input မွာ android:inputType="time" လို႔ထည့္ၿပီး Run ၾကည့္လိုက္ေနာ္။
အခ်ိန္နဲ႔ဆိုင္တာေလးေတြပဲ ေပၚလာတာေပါ့ေနာ္။
ေနာက္ထပ္က်န္ပါေသးတယ္။ သိပ္ၿပီးအသံုးမလိုလို႔ ထားခဲ့တာပါ။ အသံုးမ်ားတာေလးေတြပဲ ထည့္ေပးလိုက္ ပါတယ္။
အကုန္လံုးကို app တစ္ခုထဲမွာထည့္နည္းက Layout အေၾကာင္းမ႐ွင္းရေသးလို႔မေျပာေတာ့ပါဘူး။ တကယ္ လို႔လုပ္ခ်င္ရင္ main.xml က အကုန္လံုးကိုဖ်က္ၿပီး ေအာက္က code ေလးထည့္လိုက္ပါ။
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text Password"
android:textSize="20sp"/>
<EditText
android:inputType="textPassword"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Number Password"
android:textSize="20sp"/>
<EditText
android:inputType="numberPassword"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textSize="20sp"/>
<EditText
android:inputType="textEmailAddress"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="20sp"/>
<EditText
android:inputType="textPersonName"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone"
android:textSize="20sp"/>
<EditText
android:inputType="phone"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time"
android:textSize="20sp"/>
<EditText
android:inputType="time"
android:layout_height="wrap_content"
android:ems="10"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
အဆင္မေျပတာေလးေတြ Comment မွာေမးႏိုင္ပါတယ္ ။
သင္၏comment တစ္ေၾကာင္းသည္ ကြၽန္ုပ္အတြက္ ေနာက္ပိုစ့္မ်ားတင္ရန္ အားေဆးတစ္ခြက္ ျဖစ္ေစပါလိမ့္မည္။
ON-OFF Button
Toggle Button ဆိုတာ ဖုန္းအခ်က္ျပမီးတို႔ ဘာတို႔မွာသံုးတဲ့ အဖြင့္အပိတ္ ခလုပ္ပံုစံျဖစ္ပါတယ္။ <TextView project အသစ္လုပ္လိုက္ပါ။ ဒီနားမွာနည္းနည္းေျပာခ်င္ပါတယ္။ project အသစ္ေရြးတဲ့အခါ ကြၽန္ေတာ္ပံုမွာျပထားတဲ့ အလယ္ကဟာကိုေရြးပါ။
ဘာျဖစ္လို႔လဲဆိုေတာ့ ကြၽန္ေတာ္ေရးတဲ့ ဟာေတြနဲ႔ လြဲေနမွာစိုးလို႔ပါ။
ကဲ.... မူရင္းေခါင္းစဥ္ကို ျပန္သြားၾကတာေပါ့။
project အသစ္လုပ္လိုက္ပါ။ ၿပီးရင္ ပံုမွာျပထားတဲ့အတိုင္း ေအာက္ကcode ေတြကုိထည့္လိုက္ပါ။
<ToggleButton
android:layout_height="wrap_content"android:layout_width="wrap_content"/>
Run ၿပီးခလုပ္ေလးႏိွပ္ၾကည့္ပါ။
ON-OFF ခလုပ္ေလးရပါလိမ့္္။
ေနာက္ထပ္ခလုပ္တစ္ခုလုပ္ဖို႔ ေစာေစာကထည့္ထားတဲ့ code ေနာက္ကေန ႏွစ္ေၾကာင္းေလာက္ဆင္းလိုက္ပါ။ ၿပီးေတာ့ ဒီေအာက္က codeေလးေတြထည့္ၾကည့္ပါ။
<Switch
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
ပံုထဲကအတိုင္း ရ႐ွိပါလိမ့္မယ္။
အဲ့code ေအာက္ကေနၿပီး ႏွစ္ေၾကာင္းေလာက္ထပ္ဆင္းၿပီး ေအာက္က codeေလးေတြထပ္ ထည့္ၾကည့္ပါ။
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="mark here"/>
Run လို႔ရပါၿပီ။ အဲ့codeေတြမွာ android:text="mark here" ဆိုတဲ့ေနရာမွာ mark here ဆိုတာ ဒီမွာအမွန္ျခစ္ပါေပါ့။ အဲ့ေနရာမွာမိမိစိတ္ႀကိဳက္ ထည့္သြင္းလို႔ ရပါတယ္။
ဒီလိုေလးေပါ့။
ၿပီးရင္ အဲ့codeေတြရဲ႕ေနာက္ကေန ႏွစ္ေၾကာင္းေလာက္ ထပ္ဆင္းလိုက္ပါ။ ၿပီးရင္ဒီေအာက္ကcodeေလး ထပ္ထည့္ၿပီး run ၾကည့္မယ္ေနာ္။
<RadioButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Radio Button"/>
ဒီမွာလည္းအေပၚအတိုင္းပဲ android:text ေနရာမွာမိမိစိတ္ႀကိဳက္ထည့္လို႔ ရတယ္ေနာ္။
ဒီပံုေလးရ႐ွိပါလိမ့္မယ္။
ေနာက္ဆံုးတစ္ခုအေနနဲ႔ အဲ့code ရဲေနာက္ကေန ႏွစ္ေၾကာင္းေလာက္ ထပ္ဆင္းေပးၿပီး ေအာက္ကcode ထည့္ၿပီး run ၾကည့္ပါ။
<SeekBar
android:layout_height="wrap_content"
android:layout_width="150dp"/>
သူက်ေတာ့ android:layout_width ကို wrap_content လုပ္လို႔မရေတာ့ပါ wrap_content ဆိုလွ်င္ bar မွာအလြန္တိုသြားပါလိမ့္မယ္။ ဒါ့ေၾကာင့္ 150dp ထားလိုက္ပါတယ္။ 150dp ေနရာမွာ သင့္စိတ္ႀကိဳက္ ေျပာင္းလဲႏိုင္ပါ တယ္။ ဤwrap_content အေၾကာင္းကို ေနာက္ပိုင္းတြင္ ႐ွင္းလင္းေပးသြားပါမည္။
ဒီလိုေလးပါပဲ။
ဒီေန႔တင္သြားတဲ့ အေၾကာင္းအရာက ေလ့လာသူေတာ္ေတာ္မ်ားမ်ား ေတြ႔ဖူးၿပီးသားေတြပါပ။ဲ အဲ့လိုခလုပ္ေတြ ဘယ္လိုလုပ္လဲဆိုတာ သိေအာင္လို႔ပါ။ ေနာက္ထပ္လည္း ထပ္မံတင္ေပးသြားပါမည္။
သင္၏comment တစ္ေၾကာင္းသည္ ကြၽန္ုပ္အတြက္ ေနာက္ပိုစ့္မ်ားတင္ရန္ အားေဆးတစ္ခြက္ ျဖစ္ေစပါလိမ့္မည္။
Lesson (3)
Butoon
Lesson 2 က Tutorial အတိုင္းျပန္သြားပါ။
Project အသစ္လုပ္ပါ။ Project အသစ္လုပ္နည္းကို တင္ေပးၿပီးသားပါ။ မသိရင္
★ ★ ဒါကိုႏိွပ္ပါ ★ ★
ဒီမွာ project အသစ္လုပ္တိုင္း <LinearLayout ......./> မွာ
android:orientation="vertical"
ပါလားၾကည့္ပါ။ မပါရင္"center" ေနာက္ကထည့္ပါ။
ပံုမွာ ျပထားတဲ့ အတိုင္း
<TextView..........."Hi World"/>
ရဲ႕ ေနာက္ကေန ႏွစ္ေၾကာင္းေလာက္ ဆင္းလိုက္ပါ။ ၿပီးေတာ့ ေအာက္က codeေလးေတြ ထည့္လိုက္ပါ။
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exit"/>
ၿပီးရင္စမ္းၾကည့္ပါ။
Exit ကိုႏိွပ္ၾကည့္ပါ။ သာမန္အားျဖင့္ Exit ကိုႏိွပ္ရင္ ထြက္သြားမွာျဖစ္ပါတယ္။ ဒီမွာႏိွပ္ရင္ ဘာမွမျဖစ္ပါဘူး။ ဘာျဖစ္လို႔လဲဆိုေတာ့ ဒါ xml fileေလ ပံုစံပဲေပၚမွာပါ ဘာမွမလုပ္ေဆာင္ႏိုင္ပါဘူး။
အခုေရးလိုက္တဲ့ အေပၚက code ေတြရဲ့ေနာက္မွာ ႏွစ္ဆင့္ ေလာက္ထပ္ဆင္းလိုက္ပါ။
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Help"/>
အဲ့ code ကို ထပ္ထည့္လိုက္ပါ။
Button ႏွစ္ခုရပါၿပီ။
ေနာက္ထပ္ button 3 ခုေလာက္ထပ္လုပ္ၾကည့္ပါ။ နာမည္ေတြ ကိုေတာ့ android:text ေနာက္မွာ ေရးေပးရပါမယ္။
button ကိုColor တင္ပါမယ္။
<Button ရဲ႕ေနာက္ကေန တစ္ေၾကာင္းဆင္းလိုက္ပါ။အဲ့မွာ
android:background="#15BDE7"
ကိုထည့္ပါ။
ၿပီးရင္စမ္းၾကည့္ပါ။
ေနာက္ထပ္ မိမိႏွစ္သက္ရာ Color code ေတြထည့္ၿပီးေရးသားႏိုင္ပါတယ္။Color code ထည့္နည္းကို Lesson 2 မွာတင္ေပးၿပီးသားေနာ္။
လက္သည္ခ်ည္းပဲအားမကိုနဲ႔ ကိုယ့္ဟာကိုယ္ညႇစ္အားေလး သံုးဦး :-) :-)
သင္၏comment တစ္ေၾကာင္းသည္ ကြၽန္ုပ္အတြက္ ေနာက္ပိုစ့္မ်ားတင္ရန္ အားေဆးတစ္ခြက္ ျဖစ္ေစပါလိမ့္မည္။
Apk အသစ္ ထပ္လုပ္နည္းနဲ႔ apk နာမည္ျပင္နည္း
ကြၽန္ေတာ္တို႔လုပ္ခဲ့တဲ့ အရင္ tutorial ေတြမွာ ပထမတစ္ခုလုပ္ၿပီး ေနာက္တစ္ခုထပ္လုပ္ရင္ အရင္apk ကပ်က္သြားတယ္ေလ။ အဲ့တာဘာျဖစ္လို႔လဲလို႔ လာေမးၾကလို႔ တင္ေပးလိုက္ပါတယ္။ ဘာျဖစ္လို႔လဲဆိုေတာ့ package Name တူေနလို႔ပါ။ package name ဆိုတာ ဥပမာ com.mmapptutorial.myapp လိုမ်ိဳးေပါ့။ ပထမtutorial စလုပ္ေတာ့ နာမည္ႏွစ္ခုထည့္ရတယ္ေလ။ မွတ္မိလားမသိဘူး။ အေပၚက Name ရယ္ package name ေပါ့။ အဲ့မွာ Name ကို အဂၤလိပ္လိုပဲေရးလို႔ရတယ္ေလ Space bar ခံလို႔ မရဘူးေလ အဲ့တာကို စိတ္ႀကိဳက္ ျမန္မာလိုျဖစ္ျဖစ္ အဂၤလိပ္လိုျဖစ္ျဖစ္ ျပင္တဲ့နည္းပါ။ အရင္ဆံုး ေအာက္ကပံုမွာ ျပထားတဲ့အတိုင္း ဝင္လိုက္ပါ။
အေပၚက ပံုမွာျပထားတဲဟာေလးကို Create new project ေပၚတဲအထိႏိွပ္ပါ။
အဲ့လိုေပၚလာရင္ အဲ့့တာကိုႏိွပ္ပါ။
အရင္ကေပးထားတဲ့ package name နဲ႔မတူတာေပးေပါ့။
.
နာမည္စိတ္ႀကိဳက္ေျပာင္းနည္း
Value ကို႐ွာပါ။
ဝိုင္းျပထားတဲ့ေနရာမွာ စိတ္ႀကိဳက္ျပင္ၿပီး Run ၾကည့္ပါ။
သင္ရဲ႕ Comment တစ္ေၾကာင္းသည္ ကြၽန္ုပ္ေနာက္ post မ်ားတင္ရန္ အားေဆးတစ္ခြက္ျဖစ္ပါသည္။






















































