thaiall logomy background
ระบบปฏิบัติการแอนดรอยด์
my town
JavaScript | Reactnative | LPMuseum | Drive Hosting | WebServer |
การใช้งานแอปพลิเคชันบนแอนดรอยด์ เพื่อเขียนเว็บเพจอย่างง่าย ะบบปฏิบัติการ คือ กลุ่มโปรแกรมซึ่งได้รับการจัดระเบียบให้เป็นส่วนเชื่อมโยงระหว่างเครื่อง และผู้ใช้ โดยจะเอื้ออำนวยการพัฒนาและการใช้โปรแกรมต่าง ๆ รวมถึงการจัดสรรทรัพยากรต่าง ๆ ให้มีประสิทธิผลที่ดี ดังนั้นทุกระบบปฏิบัติการ เช่น windows, ios, และ android ย่อมมีเป้าหมายเดียวกัน คือ 1) เอื้ออำนวยการพัฒนา 2) การใช้โปรแกรม และ 3) จัดสรรทรัพยากร
ทเรียนนี้ เสนอแนวทางการเรียนรู้การใช้แอปพลิเคชัน การจัดการทรัพยากร และการพัฒนางานที่เชื่อมโยงอย่างเป็นระบบ มีขั้นตอนดังนี้ 1) จัดการแฟ้มในอุปกรณ์ ด้วย File manager application เพื่อคัดลอก ย้าย หรือลบแฟ้มได้ 2) ใช้เบราว์เซอร์ เช่น Chrome, Safari, Firefox, Opera, หรือ Edge เปิดแฟ้มเอกสาร หรือภาพในอุปกรณ์ได้ และรู้ตำแหน่งที่อยู่อย่างชัดเจน 3) ใช้แอปพลิเคชันประเภท Text Editor แบบ Notepad บน Windows หรือ บน Android OS ขอแนะนำ Droid edit free, Code Editor, หรือ QuickEdit Text Editor ส่วนบน iOS ขอแนะนำ Code Editor, Quick Editor - Text & Code, หรือ Koder Code Editor 4) เชื่อมโยงแฟ้มเว็บเพจ .htm และ .jpg แล้วสามารถออกแบบ Webpage Layout และการเชื่อมโยงระหว่างเว็บเพจได้ 5) เปิดผลงานใน Local storage หรืออัพโหลดไปเผยแพร่ใน Google Drive หรือ OneDrive แล้วเชื่อมกับ drv.tw ได้
การสร้าง App ที่ใช้ Top Tab Navigator บน Thunkable.com
1. Layout : Top Tab Navigator (4 tab)
2. เปลี่ยนสีพื้นให้ Home, About, Contact, Setting
3. ใส่ Webview ใน About มี url เป็น AdminLTE
- ใส่ Label แล้วพิมพ์ข้อความแนะนำ ใน Home
4. ใส่ Button ใน Home เพื่อสั่งลิงค์ไป About
- Blocks : when Button1 click
- do navigate to "About"
5. ใส่ Text input ใน Contact
6. ใส่ Button ใน Contact
- Blocks : when Button2 click
- do open link "https://github.com"
- on error navigate to "Home"
7. Preview

gthaiall@
เปรียบเทียบ thunkable กับ mit app inventor
No-Code / Low-Code Development Platform
thunkable.com โดย ครูอภิวัฒน์
/programming/helloworld.htm
/android
เล่าเรื่องพัฒนา app บน android studio ใน Blog

4shared.com
ตอนที่ 1 การพัฒนา app สำหรับใช้งานบน Smart Phone ที่ลง Android
ตอนที่ 2 ทำ App เรียกโฮมเพจมาแสดงใน Smart Phone
ตอนที่ 3 ใช้ CustomTabs แทน WebView สั่งเปิดโฮมเพจ
ตอนที่ 4 ทำหน้าเพจที่มีข้อมูลมากจนต้อง scroll ลงไป และการเพิ่ม icon ประจำแอพ
ตอนที่ 5 สร้างปุ่ม Close App แบบ VectorDrawable ตัวปุ่มภาพหามาได้หลายวิธี และการสั่งเรียกบทความต่างกัน
ตอนที่ 6 การใช้ชื่อภาพแบบซีรี่กำหนดลำดับการแสดงภาพผ่านคลาส TextUtils แทน String.join
ตอนที่ 7 การมีภาพประกอบบทความแบบเป็นพื้นหลัง และแยกเฟรม เปลี่ยนบทความด้ายการลากซ้ายขวา และเปลี่ยนปุ่มลอยทับ
ตอนที่ 8 การใส่ภาพและคำสั่ง HTML ใน TextView ต่างกันทั้ง Java, Layout และ String
ตอนที่ 8.1 สิ่งที่ทำได้ และไม่ได้ในการใช้ HTML ใน TextView
ตอนที่ 9 Layout ของการแจ้งเตือน และการสร้าง Layout at Runtime และเมนู กับการแสดงภาพต่อตาม Vertical
ตอนที่ 10 สำรวจ Layout และ properties ที่น่าสนใจ 6 Layout
Add Code from a Template เคยอ่านเรื่อง Add Code from a Template จาก android.com พบว่าแต่ละ Template จะมี Activity, Layout, String, Drawable, Style, Menu เป็นต้น ทำให้เรียนรู้การเขียน code และหน้าตาของผลงานที่เราต้องการได้เร็ว ไม่ใช่การเริ่มต้นจาก 0 ใน Android Studio 2.3.3 ที่ผมใช้อยู่มี Template ให้เลือก 12 รูปแบบ ถ้าไม่ต้องการใช้ Template ก็เลือก Add no activity ได้เลย อยู่มุมบนซ้ายร่่วมกับ 12 Template ที่มีมาให้เลือก
My app in Google Play
IT Article คือ Application ที่นำเสนอบทความมากกว่า 300 บทความ ทั้งหมดเป็นงานเขียนเกี่ยวกับเทคโนโลยีในชีวิตประจำวัน เคยถูกพิมพ์ในหนังสือพิมพ์ฅนเมืองเหนือ ตั้งแต่เดือนตุลาคม 2548 จนถึงปัจจุบันสัปดาห์ละ 1 เรื่อง และนำเสนอผ่านเว็บไซต์ thaiall.com ในรูปของเว็บเพจทั้งแบบ Printable และ Word สำหรับบทความใน app จะช่วยให้ผู้อ่านที่ติดตั้ง app แล้ว สามารถอ่านบทความได้แบบออฟไลน์ แม้อุปกรณ์ไม่เชื่อมต่ออินเทอร์เน็ตก็ตาม
IT Article for Smartphone, TabletPC on Android
app: itarticle.apk for android device
source: itarticle.zip for eclipse
Google Play : App page
Introduction to Android Apps

ซีรี่กว่า 200 ตอน

eclipse เบื้องต้น
แอนดรอยด์ (Android) หรือ กูเกิลแอนดรอยด์ (Google Android) คือ ระบบปฏิบัติการที่พัฒนาโดยกูเกิล เป็นแพลตฟอร์ม (Platform) สำหรับอุปกรณ์อิเล็กทรอนิกส์ อาทิ คอมพิวเตอร์ โทรศัพท์เคลื่อนที่ แท็บเล็ตพีซี เปิดตัว 5 พฤศจิกายน 2550 โดยมีบริษัทกูเกิล เป็นผู้ถือสิทธิบัตรในตราสัญลักษณ์ ชื่อ และ รหัสต้นฉบับ (Source Code) ของแอนดรอยด์ ภายใต้เงื่อนไขการพัฒนาแบบ GNL โดยเปิดให้นักพัฒนา (Developer) สามารถนำรหัสต้นฉบับ ไปพัฒนาปรับแต่งได้อย่างเปิดเผย (Open Source) ทำให้แอนดรอยด์มีผู้เข้าร่วมพัฒนาเป็นจำนวนมาก
Download : Android Studio [1.9 GB]
Download : JDK : Java Development Kit :: Eclipse Classic :: Android SDK :: Android.com Bluestacks.com
บทเรียนเกี่ยวกับ android (ผมได้เรียนกับ อ.ชัยวัฒน์ สมศรี ช่วยให้เข้าใจอะไรได้ง่ายขึ้นเยอะครับ)
+ บทที่ 1 การเขียนแอพพลิเคชั่น โดย eclipse facebook fan page หรือ lightbox
+ บทที่ 2 การส่ง app ที่เขียนขึ้นเข้า Google Play : Android Market [gthaiall]
การเปิดบริการต่าง ๆ บนสมาร์ทโฟน
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ขั้นตอนการทำให้ Smartphone ที่ใช้ android เปิดบริการเว็บ และฐานข้อมูล MySQL
ทดสอบกับ F-Phone F823 และ Samsung Galaxy Tab 10.1 มีกระบวนการเหมือนกัน
1. เริ่มต้นด้วยการดาวน์โหลด และติดตั้ง App: Palapa Web Server ของ AlfanLA
หลังติดตั้งแล้วอุปกรณ์จะให้บริการ ตาม Package ต่อไปนี้
Lighttpd 1.4.35, PHP 5.5.15, MySQL 5.1.69, MSMTP 1.4.32, Web Admin 2.1.0
2. เมื่อเปิดแอพขึ้น มาก็จะถามการ install packages ให้กดปุ่ม install
3. เมื่อ install packages ทั้งหมดก็จะพบหน้า home ที่สามารถสั่ง START ALL SERVICES ได้
4. พบในช่อง IP 127.0.0.1,192.168.2.5 และ Port เบอร์ 8080 โดยใช้งานในวง Wifi
5. ทดสอบใน Tablet โดยเปิด Browser แล้วกำหนด URL เป็น http://127.0.0.1:8080
หรือเปิดในเครื่องอื่นผ่าน Firefox โดยกำหนด URL เป็น http://192.168.2.5:8080
ก็จะพบว่า Webserver เปิดให้บริการเรียบร้อยแล้ว
มี Root Directory อยู่ที่ /mnt/sdcard/pws/www
+ <a href="/blog/burin/6832/">http://www.thaiall.com/blog/burin/6832/</a>
+ <a href="/learn/sader.htm">http://www.thaiall.com/learn/sader.htm</a>
การเปิดบริการ FTP Server บนสมาร์ทโฟน
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ขั้นตอนการทำให้ Smartphone ที่ใช้ android เปิดบริการ File Transfer Protocol (FTP)
โดยรับการเชื่อมต่อจาก FTP Client
1. เริ่มต้นด้วยการดาวน์โหลด และติดตั้ง App : FTPServer ของ Andreas Liebig
2. เมื่อติดตั้งแล้ว การเปิด app ครั้งแรกต้องกำหนดค่าของเครื่องบริการ
- User: admin
- Pass: admin
- Port: 1024
- Allowed connections: thaialldotcom (เป็นเครือข่าย wifi ที่อนุญาต)
- Default directory: /mnt/sdcard/pws/www
3. แล้วสั่ง Start FTP Service
พบข้อมูลบน title เป็นหมายเลขไอพี และพอร์ต : 192.168.2.11:1024
4. ทดสอบส่งแฟ้ม index.html ใน c:\ จากเครื่อง PC โดยใช้ DOS Command
cmd> ftp
ftp> open 192.168.2.11 1024
ftp> lcd c:\
ftp> put index.html
ftp> bye
+ <a href="/perlphpasp/source.pl?key=9116">code ภาษา PHP ที่ใช้ในการบริหารจัดการ MySQL</a>
การใช้ MySQL Client บนสมาร์ทโฟน
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ขั้นตอนการทำให้ Smartphone ที่ใช้ android เข้าถึง MySQL Server
โดยใช้ MySQL Client และเขียน SQL Command ได้
1. เริ่มต้นด้วยการดาวน์โหลด และติดตั้ง App : crox mysql client ของ Pedro de la vega
2. เมื่อติดตั้งแล้ว การเปิด app ครั้งแรกต้องสร้างการเชื่อมต่อ
- ชื่อ: admin
- เซิร์ฟเวอร์: 192.168.2.11
- พอร์ท: 3306
- ผู้ใช้: root
- รหัสผ่าน: adminadmin
3. เมื่อคลิ๊กที่ชื่อจากหน้ารายการการเชื่อมต่อ เลือก เชื่อมต่อ
จะแสดงรายการตารางทั้งหมดในฐานข้อมูล MySQL
4. เลือก สร้างแบบสอบถาม จากตัวเลือกมุมบนขวา แล้วสร้างฐานข้อมูลใหม่
ด้วยคำสั่ง create database me01; แล้วสั่งประมวลผล
พบคำว่า ได้รับผล 1 เรกคอร์ด ถ้าเลือก รีเฟรช ก็จะเลือกฐานใหม่ได้
5. เลือกสั่งสร้างตารางใน SQL Command
ด้วยคำสั่ง create table t1 (f1 int, f2 char(10));
6. เลือกสั่งแทรกระเบียนใหม่ในตาราง ผ่าน SQL Command
ด้วยคำสั่ง insert into t1 values(1,"boy");
แล้วสั่ง select * from t1;
7. เลือกสั่งลบตาราง ด้วยคำสั่ง drop table t1;
+ <a href="https://www.facebook.com/ajburin/media_set?set=a.10153180889298895.1073741856.814248894">รวมภาพหน้าจอที่จับจอภาพไว้ (Capture Screen) share in fb</a>
ใช้กลุ่ม App บน Smart phone เชื่อมกัน
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Smartphone : Samsung J6+
1. Download & Install
1.1 Server for PHP : PHP 7.3.0 - 213 MB
    0.0.0.0:8080
    https://play.google.com/store/apps/details?id=com.esminis.server.php&hl=en_US
1.2 MariaDB Server : 10.3.10 - 42 MB
    0.0.0.0:3306
    https://play.google.com/store/apps/details?id=com.esminis.server.mariadb
1.3 FTP Server : The olive tree
    https://play.google.com/store/apps/details?id=com.theolivetree.ftpserver
     
2. Check parameter
2.1 Server for PHP
    Android : http://192.168.43.1:8080
    Data directory : /storage/emulated/0/www
    HTDOCS : /storage/emulated/0/www/public
2.2 FTP Server
    User : francis
    Password : francis
    Custom folder : / => /storage/emulated/0
    Anonymous ผ่าน Browser ที่ ftp://192.168.43.1:2221
2.3 Desktop
    IP : 192.168.43.108
    - Script File : Joomla
    - Script File : phpMyAdmin - xampp 7.1
2.4 MariaDB
    user: "root" password: ""
     
3. Upload Files from Desktop to Android
ใช้ Filezilla บน Desktop
    - Joomla 3.9.1 (<a href="joomla391_android.rar">joomla391_android.rar</a> + dump.sql)
        เข้า /storage/emulated/0/www/public
    - phpMyAdmin 4.7.0 (<a href="phpmyadmin470_android.rar">phpmyadmin470_android.rar</a> in xampp 7.1)
        เข้า /storage/emulated/0/www/public/phpMyAdmin
 
4. เปิด phpMyAdmin บน Desktop
4.1 http://192.168.43.1:8080/phpMyAdmin/
config.inc.php -> $cfg['Servers'][$i]['host'] = 'localhost'; // พบปัญหา
#2002 - No such file or directory — The server is not responding (or the local server's socket is not correctly configured).
config.inc.php -> $cfg['Servers'][$i]['host'] = '127.0.0.1'; // ok
4.2 สร้าง Database ชื่อ myjoomla
4.3 import : dump.sql ที่เก็บไว้ใน /myjoomlasql
result : 86 Tables
 
5. แก้ไข configuration.php ของ Joomla
เป็น public $host = '127.0.0.1';
 
6. http://192.168.43.1:8080/
    เข้าได้ทั้ง Frontend และ /administrator
    user: admin password : admin
    user: hot password: honda
    user: top password: toyota
 
7. On android สามารถใช้ได้หลาย URL
    http://192.168.43.1:8080/
    http://localhost:8080/
    http://127.0.0.1:8080/
ใช้ Android studio (เริ่มบนเครื่อง PC : 4 มีนาคม 2562)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
1. เข้า https://developer.android.com/studio
Download : android-studio-ide-182.5264788-windows.exe 947 MB
แล้วก็ install
- ในเครื่องมี c:\program files\java\jre อยูแล้ว จึงไม่ติดตั้งเพิ่ม
- Data sharing : Settings | Appearance % Behavior | System Settings | Data Sharing
- ตอนติดตั้งไม่ได้เลือก จึงคลิ๊ก Don't send แทนที่จะคลิ๊ก Send usage statistics to Google
- ก็ไม่ได้เปลี่ยน option ตอนติดตั้งกด next อย่างเดียว
- Downloading Component
(repository 339.1 MB, sdk-tools 148.9 MB, sources 40.6MB, platform 72.1 MB,
emulator 257.9 MB, build-tools 55.7 MB)
 
Failed to install Intel HAXM. For details, please check the installation log: "C:\Users\LAB\AppData\Local\Temp\haxm_log.txt"
HAXM installation failed. To install HAXM follow the instructions found at: https://software.intel.com/android/articles/installation-instructions-for-intel-hardware-accelerated-execution-manager-windows
 
2. Welcome to Android Studio 3.3.1
- [Start a new Android Studio project]
- Open an existing Android Studio project
- Check out project from Version Control
- Profile or debug APK
- Import project (Gradle, Eclipse ADT, etc.)
- Import an Android code sample
 
3. Phone and Tablet
[Navigation Drawer Activity]
Configure your project
Name = My Application
API 15: Android 4.0.3 (IceCreamSandwich)
 
4. Project
[MyApplication Tab]
    .idea
    app
    gradle
    .gitignore
    build.gradle
    gradle.properties
    gradlew
    gradlew.bat
    local.properties
    MyApplication.iml
    settings.gradle
[Gradle Scripts]
    build.gradle
    gradle-wrapper.properties
    gradle.properties
    settings.gradle
    local.properties
 
5. รอ Build: จนพบ completed successfully
ครั้งแรกรอให้การทำงานใน status bar จบจบ
จะพบ tab: MainActivity.java, content_main.xml
 
6. [content_main.xml]
กดสลับไปมาระหว่าง 
- Design ที่ปรับค่า Attributes ได้
- Text ที่เป็น xml code ได้
เพื่อดูภาพหน้าจอการทำงาน
 
7. กดปุ่ม > เพื่อ run app
หรือ Menu, Run หรือ Shift + F10
 
8. ยังไม่พบ device
Create new Virtual Device
- Nexus 5X , 5.2in, 1080*1920, 420dpi
- Oreo Download , 26, x86, android 8.0 (733.7 MB)
- Nougat Download , 24, x86, android 7.0 (775.1 MB)
โทรศัพท์ของผมใช้ 8.1 Oreo ซึ่งรองรับ 8.0 แน่นอน
Creat AVD Name = Nexus 5X API 26
Creat AVD Name = Nexus 5X API 24
 
9. หลังเลือก Device
Instant Run : Install and Continue
 
10.Event log
Problem : x86 emulation currently requires hardware acceleration!
10.1 check : Tools, SDK Manager, Android SDK, SDK Tools
พบว่า  Intel x86 Emulator Accelerator (HAXM instalelr) 7.3.2 : installed
10.2 solution:
C:\Users\LAB\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm-android.exe
https://ourcodeworld.com/articles/read/296/how-to-solve-android-avd-error-in-windows-x86-emulation-currently-requires-hardware-acceleration
 
11. Docker Desktop Service
Stop & Manual
Setting : General
uncheck : Start Docker Desktop when you login
uncheck : Automatically check for updates
 
12. hyper-v
Turn Windows Features On or Off
 
13 content-main.xml
เปลี่ยน "hello world!" เป็น "hello world"
แก้ไขผ่าน design, attributes tab, TextView text="hello world"
 
14. กด apply change เพื่อทำ instant run
รอสักพัก การเปลี่ยนแปลงก็จะปรากฎใน emulator
 
15. content_main.xml
ต้องการ คลิ๊ก hello world!
ถ้าค่าของ Textview เป็น 0 ก็ใส่ 1 เข้าไปแทน
- android:id="@+id/text1"
- android:clickable="true"
 
16. MainActivity.java
เพิ่ม method ใน public class MainActivity {}
ทำให้เกิดการจัดคู่ระหว่าง onClick ใน content_main.xml และ MainActivity.java
ตำแหน่งแรก
    import android.widget.TextView;
 
ตำแหน่งที่สอง
    เพิ่มใน protected void onCreate(){}
        TextView t = (TextView)findViewById(R.id.text1);
        t.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TextView t = (TextView)findViewById(R.id.text1);
                //Integer v = Integer.parseInt(t.getText().toString()) + 1;
                if(t.getText().equals("Hello World!")) {
                   t.setText(String.valueOf("0"));
                } else{
                    int t1 = Integer.parseInt(t.getText().toString()) + 1;
                    t.setText(Integer.toString(t1));
                }
            }
        });
https://devahoy.com/posts/android-button-onclick-listener-tutorial/
 
17. การเพิ่มภาพใน drawable
ลากวางได้เลย
ใน MyApplication, app, src, main, res, drawable
พบ sample.png
 
18. การเพิ่มภาพใน page บน Design view
- Palette, Common, ImageView ลากลงไปใน page
- เลือก Project แล้ว click ภาพ
- ใช้ mouse ปรับขนาดของ layout_width และ layout_height ของ imageView1 ได้
- กำหนดเป็น 100dp
 
19. เพิ่มคำสั่งใน MainActivity.java
import android.widget.ImageView;
 
        ImageView i = (ImageView)findViewById(R.id.imageView3);
        i.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TextView t = (TextView)findViewById(R.id.text1);
                if(t.getText().equals("Hello World!")) {
                    t.setText(String.valueOf("0"));
                } else{
                    int t1 = Integer.parseInt(t.getText().toString()) + 1;
                    t.setText(Integer.toString(t1));
                }
            }
        });
 
20. copy content_main.xml เป็น two.xml
https://chrisrisner.com/Using-Fragments-with-the-Navigation-Drawer-Activity
https://medium.com/android-hunger/how-to-implement-navigation-drawer-in-your-android-app-with-an-example-48e08530339f
http://www.arjunsk.com/android/how-to-use-fragment-layout-and-scroll-layout-in-android-studio/
https://stablekernel.com/using-fragments-to-simplify-android-navigation-drawers/
*** https://www.simplifiedcoding.net/android-navigation-drawer-example-using-fragments/
https://stackoverflow.com/questions/21192386/android-fragment-onclick-button-method
 
[สร้าง layout]
app, res, layout : new - Layout resource file
fragment1.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">
 
</android.support.constraint.ConstraintLayout>
แล้วสร้าง 2 วัตถุ
- android:id="@+id/button1"
- android:id="@+id/text1"
  android:paddingTop="50dp" จะได้ไม่ชนกับ button1
         
[ปรับ content_main]
content_main.xml
ลบ TextView เปลี่ยนเป็น FrameLayout
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
 
[สร้าง java]
ใน  package com.example.navfragment;
menu1.java
package com.example.navfragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
public class menu1 extends Fragment implements View.OnClickListener {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment1, container, false);
        Button b = (Button) v.findViewById(R.id.button1);
        b.setOnClickListener(this);
        TextView t = (TextView) v.findViewById(R.id.text1);
        t.setOnClickListener(this);
        View tv = v.findViewById(R.id.text1);
        ((TextView)tv).setText("hello");
        return v;
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);       
        getActivity().setTitle("Menu 1");
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button1:
                //System.exit(1);
                View tv1 = v.findViewById(R.id.button1);
                ((TextView)tv1).setText("1");
                break;
            case R.id.text1:
                TextView tv2 = v.findViewById(R.id.text1);
                if(tv2.getText().equals("hello")) {
                    tv2.setText(String.valueOf("0"));
                } else{
                    int tmp = Integer.parseInt(tv2.getText().toString()) + 1;
                    tv2.setText(Integer.toString(tmp));
                }
                break;
        }
    }
}
         
[MainActivity.java]
ใน app, java, com.example.navfragment
1. สร้าง method
    private void displaySelectedScreen(int itemId) {
        //creating fragment object
        Fragment fragment = null;
        //initializing the fragment object which is selected
        switch (itemId) {
            case R.id.nav_camera:
                fragment = new fragment(); // MainActivity
                break;     
            case R.id.nav_gallery:
                fragment = new menu1();
                break;           
        }
  
        //replacing the fragment
        if (fragment != null) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.content_frame, fragment);
            ft.commit();
        }
  
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
    }
2. เพิ่มบรรทัดสุดท้ายของ on create 
displaySelectedScreen(R.id.nav_camera);
 
3. ใน public boolean onNavigationItemSelected(MenuItem item)
เหลือ 2 บรรทัด
displaySelectedScreen(item.getItemId());
return true;
 
c:/users/%USERNAME%/AndroidStudioProjects/navfragment
Source : <a href="navfragment.zip">navfragment.zip</a> 142,736 bytes
Build : <a href="navfragment.apk">navfragment.apk</a> 2,277,379 bytes
Java : webview
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
New Webview : ว่าง ๆ มาเลย
mywebview.java
package com.example.navfragment;
public class mywebview {
}
mywebview.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">
 
</android.support.constraint.ConstraintLayout>
 
    <WebView
        android:id="@+id/myWebView"
        android:layout_width="395dp"
        android:layout_height="715dp"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp" />
     
package com.example.navfragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
public class mywebview extends Fragment implements View.OnClickListener {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.mywebview, container, false);
        WebView b = (WebView) v.findViewById(R.id.myWebView);
        return v;
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        getActivity().setTitle("Miss grand 2017");
    }
    @Override
    public void onClick(View v) {
    }
}
การประมวลผล apk บน chrome นื่องจากระบบปฏิบัติการ android ได้รับความนิยมเพิ่มขึ้น แอปพลิเคชันที่ถูกพัฒนามี extension ลงท้ายด้วย .apk สามารถนำไปติดตั้งใช้งานบน smart phone มีให้ดาวน์โหลดกันอย่างแพร่หลาย ในกรณีที่ผู้ใช้ หรือผู้พัฒนาได้รับแฟ้ม .apk แล้ว ต้องการติดตั้งบน smart phone สามารถทดสอบมาประมวลผลบน chrome browser แบบ online มีขั้นตอนดังนี้ 1) เริ่มจากการเปิด chrome browser แล้วเปิดเว็บไซต์ ApkOnline APK manager for Android emulator จะพบ "Add to chrome" ให้คลิ๊กเพื่อเพิ่ม extension เข้า Extension 2) จากนั้นสั่งเปิดใช้ ApkOnline จากการคลิ๊กเลือก Extensions icon บน Address bar 3) พบ Icon menu ของ ApkOnline แล้วคลิ๊ก Upload เลือกแฟ้ม .apk 4) คลิ๊กขวา Application ที่ได้อัพโหลดขึ้นไปบน ApkOnline แล้วเลือก run หรือดับเบิ้ลคลิ๊ก 5) คลิ๊กปุ่ม Start แล้ว Wait ประมาณ 20 วินาที แล้วคลิ๊กปุ่ม Enter แล้วรออีก 40 วินาที 6) พบ Emulator ที่มีหน้าจอเหมือน Tablet หรือ Smartphone และ application ให้ใช้งาน 7) บาง application พบปัญหา "Critical Error Occured!" คือ ประมวลผลไม่ได้ อาจต้องเลือกไปใช้ Bluestack 5 แทน
thaiall.com/android/itarticle.apk
thaiall.com/android/
rspsocial
ใช้เวลาโหลดเว็บเพจ = 342 มิลลิวินาที สูง = 7376 จุด กว้าง = 1264 จุด
Thaiall.com
Thailand Web Stat