-
Basic4Android 初學者指南 英文版下载
资源介绍
1 Getting started........................................................................................................................7
1.1 Installing Basic4Android and Android SDK ....................................................................7
1.1.1 Install and configure Basic4Android ........................................................................9
1.2 Installing Android Emulator........................................................................................... 10
2 My first program (MyFirstProgram.b4a)............................................................................... 15
3 Second program (SecondProgram.b4a) ................................................................................. 33
4 The IDE ............................................................................................................................... 46
4.1 Menu and Toolbar.......................................................................................................... 47
4.1.1 Toolbar .................................................................................................................. 47
4.1.2 File menu ............................................................................................................... 48
4.1.3 Edit menu............................................................................................................... 48
4.1.4 Project menu .......................................................................................................... 49
4.1.5 Tools menu ............................................................................................................ 50
4.2 Code area....................................................................................................................... 52
4.2.1 Undo – Redo ............................................................................................. 52
4.2.2 Collapse a subroutine ............................................................................................. 52
4.2.3 Collapse a Region .................................................................................................. 53
4.2.4 Collapse the whole code......................................................................................... 54
4.2.5 Commenting and uncommenting code ...................................................... 55
4.2.6 Bookmarks .................................................................................. 55
4.2.7 Indentation ............................................................................................... 56
4.2.8 Autocomplete ................................................................................................. 58
4.2.9 Jump to a subroutine .............................................................................................. 60
4.2.10 Highlighting occurences of words .......................................................................... 61
4.2.11 Debugging ............................................................................................................. 62
4.2.12 Breakpoints............................................................................................................ 64
4.3 Tabs.............................................................................................................................. 67
4.3.1 Module and subroutine lists ............................................................... 67
4.3.2 Files ....................................................................................................... 68
4.3.3 Logs ...................................................................................................... 69
4.3.4 Libs ........................................................................................................ 70
5 Screen sizes and resolutions................................................................................................... 71
5.1 Specilal functions like 50%x, 50dip ............................................................................. 76
5.1.1 PerXToCurrent, PerYToCurrent - 50%x................................................................. 76
5.1.2 DipToCurrent - 50dip............................................................................................. 76
6 The Emulator........................................................................................................................ 77
6.1 Launch an Emulator....................................................................................................... 77
6.2 Generate a new Emulator............................................................................................... 79
6.3 Emulator problems......................................................................................................... 81
6.3.1 Process timeout ...................................................................................................... 82
7 B4A Bridge ........................................................................................................................... 83
8 The Designer ......................................................................................................................... 86
8.1 The menu....................................................................................................................... 87
8.1.1 File menu ............................................................................................................... 87
8.1.2 AddView menu ...................................................................................................... 87
8.1.3 The Tools menu ..................................................................................................... 88
8.2 Tools ............................................................................................................................. 89
8.2.1 Generate Members ................................................................................................. 89
8.2.2 BringTo Front ........................................................................................................ 90
Table of contents 3 Basic4Android Beginner's Guide
8.2.3 Duplicate Selected View ........................................................................................ 90
8.2.4 Remove Selected View .......................................................................................... 91
8.2.5 Change grid............................................................................................................ 91
8.2.6 Connect device or emulator.................................................................................... 92
8.3 General settings ............................................................................................................. 92
8.4 Image files ..................................................................................................................... 93
8.5 Properties list ................................................................................................................. 94
8.6 Layout variants .............................................................................................................. 96
8.7 The Abstract Designer ................................................................................................. 101
8.7.1 The menu ............................................................................................................. 102
8.7.2 Example............................................................................................................... 103
8.8 Adding views by code.................................................................................................. 106
9 Process and Activity life cycle............................................................................................. 109
10 Variables and objects....................................................................................................... 113
10.1 Variable Types............................................................................................................. 113
10.2 Names of variables ...................................................................................................... 114
10.3 Declaring variables ...................................................................................................... 114
10.3.1 Simple variables................................................................................................... 114
10.3.2 Array variables..................................................................................................... 115
10.3.3 Array of views (objects) ....................................................................................... 117
10.3.4 Type variables...................................................................................................... 118
10.4 Casting ........................................................................................................................ 119
10.5 Scope.......................................................................................................................... 120
10.5.1 Process variables.................................................................................................. 120
10.5.2 Activity variables ................................................................................................. 120
10.5.3 Local variables..................................................................................................... 120
10.6 Tips ............................................................................................................................. 121
11 Modules.......................................................................................................................... 122
11.1 Activity modules.......................................................................................................... 123
11.2 Code modules .............................................................................................................. 124
11.3 Service modules........................................................................................................... 125
12 Example programs........................................................................................................... 126
12.1 User interfaces ............................................................................................................. 126
12.1.1 Menu example (UserInterfaceMenu.b4a)............................................................. 127
12.1.2 TabHost example (UserInterfaceTabHost.b4a) ................................................... 128
12.1.3 Button toolbox example (UserInterfaceButtonToolbox.b4a)................................ 129
12.2 Program with 3 Activities (ThreeActivityExample.b4a) .............................................. 130
12.3 ScrollView examples ................................................................................................... 137
12.3.1 ScrollView example program............................................................................... 138
13 SQLite Database.............................................................................................................. 149
13.1 SQLite Database basics................................................................................................ 149
13.2 SQLite Database example program.............................................................................. 152
13.2.1 Editing ................................................................................................................. 154
13.2.2 Filtering ............................................................................................................... 155
13.2.3 Beginning of the code .......................................................................................... 156
13.2.4 Read the table ...................................................................................................... 159
13.2.5 Modify a data set.................................................................................................. 161
13.2.6 Add a data set to the database............................................................................... 162
13.2.7 Delete a data set from the database....................................................................... 164
13.2.8 Positioning of the EditText Views in the Edit panel.............................................. 165
14 GPS................................................................................................................................ 166
14.1 GPS Library................................................................................................................. 166
14.1.1 GPS Object .......................................................................................................... 166
Table of contents 4 Basic4Android Beginner's Guide
14.1.2 GPS Satellite........................................................................................................ 167
14.1.3 GPS Location....................................................................................................... 167
14.2 GPS Program............................................................................................................... 168
14.2.1 General explanations............................................................................................ 171
14.2.2 Setup.................................................................................................................... 172
14.2.3 GPS display ......................................................................................................... 173
14.2.4 Satellites .............................................................................................................. 174
14.2.5 Map display ......................................................................................................... 175
14.2.6 GPS path.............................................................................................................. 177
14.3 GPS Program Code...................................................................................................... 181
14.3.1 Initialization of the GPS....................................................................................... 182
14.3.2 Button with tooltip ............................................................................................... 183
14.3.3 Button with tooltip and additional buttons ............................................................ 186
14.3.4 GPS Calculate distance scales .............................................................................. 189
14.3.5 Drawing GPS position.......................................................................................... 190
15 Basic language................................................................................................................. 193
15.1 Program flow............................................................................................................... 193
15.1.1 Process_Globals routine ....................................................................................... 193
15.1.2 Globals routine..................................................................................................... 194
15.1.3 Activity_Create (FirstTime As Boolean) routine .................................................. 194
15.1.4 Activity_Resume routine...................................................................................... 194
15.1.5 Activity_Pause (UserClosed As Boolean) routine................................................. 194
15.2 Expressions.................................................................................................................. 196
15.2.1 Mathematical expressions .................................................................................... 196
15.2.2 Relational expressions.......................................................................................... 197
15.2.3 Boolean expressions............................................................................................. 197
15.3 Conditional statements................................................................................................. 197
15.3.1 If – Then – End If................................................................................................. 198
15.3.2 Select – Case........................................................................................................ 199
15.4 Loop structures ............................................................................................................ 201
15.4.1 For – Next............................................................................................................ 201
15.4.2 Do - Loop ............................................................................................................ 202
15.5 Subs............................................................................................................................ 203
15.5.1 Declaring ............................................................................................................. 203
15.5.2 Calling a Sub........................................................................................................ 203
15.5.3 Naming ................................................................................................................ 203
15.5.4 Parameters ........................................................................................................... 204
15.5.5 Returned value ..................................................................................................... 204
15.6 Events......................................................................................................................... 205
15.7 Libraries ...................................................................................................................... 208
15.7.1 Standard libraries ................................................................................................. 208
15.7.2 Additional libraries folder .................................................................................... 208
15.7.3 Error message "Are you missing a library reference?" .......................................... 209
15.8 String manipulation ..................................................................................................... 210
15.9 Timers ......................................................................................................................... 211
15.10 Files......................................................................................................................... 212
15.10.1 File object ........................................................................................................ 212
15.10.2 TextWriter........................................................................................................ 214
15.10.3 TextReader....................................................................................................... 215
15.10.4 Text encoding................................................................................................... 216
16 Graphics / Drawing.......................................................................................................... 218
16.1 Overview..................................................................................................................... 218
16.2 Drawing test programs................................................................................................. 220
Table of contents 5 Basic4Android Beginner's Guide
16.2.1 Drawing rotating bitmaps / RotatingNeedle.......................................................... 220
16.2.2 Simple draw functions.......................................................................................... 225
17 Widgets, home screen widgets ......................................................................................... 234
17.1 Widgets Part I............................................................................................................. 234
17.2 Widgets Part II............................................................................................................ 237
18 B4A Keywords................................................................................................................ 240
18.1 Bit ............................................................................................................................... 240
18.2 DateTime..................................................................................................................... 241
18.3 Exception..................................................................................................................... 244
18.4 Keywords .................................................................................................................... 245
18.5 LayoutValues............................................................................................................... 257
18.6 String.......................................................................................................................... 258
18.7 StringBuilder ............................................................................................................... 260
18.8 Timer.......................................................................................................................... 262
19 Views .............................................................................................................................. 264
19.1 Activity....................................................................................................................... 264
19.2 Button......................................................................................................................... 268
19.3 CheckBox.................................................................................................................... 271
19.4 EditText....................................................................................................................... 274
19.5 ImageView .................................................................................................................. 279
19.6 Label ........................................................................................................................... 282
19.7 ListView...................................................................................................................... 285
19.8 Panel........................................................................................................................... 290
19.9 ProgressBar ................................................................................................................. 293
19.10 RadioButton............................................................................................................. 295
19.11 ScrollView............................................................................................................... 298
19.12 SeekBar ................................................................................................................... 301
19.13 Spinner .................................................................................................................... 304
19.14 TabHost ................................................................................................................... 308
19.15 ToggleButton........................................................................................................... 312
19.16 View........................................................................................................................ 315
19.17 WebView................................................................................................................. 317
20 VB6 versus B4A.............................................................................................................. 321
21 FAQ ............................................................................................................................... 326
21.1 "Please save project first" message............................................................................. 326
21.2 "Are you missing a library reference" message........................................................... 326
21.3 How loading / updating a library.................................................................................. 327
21.4 When do we need to 'Initialize' and when not............................................................. 327
21.5 Split a long line into two or more lines......................................................................... 328
21.6 Avoid closing an application........................................................................................ 328
21.7 Unwanted events like Click, Touch or others ............................................................... 329
21.8 Adding a Menu item.................................................................................................... 329
21.9 How do I remove a View with the Designer................................................................. 330
21.10 "Process has timeout" message............................................................................... 330
21.11 Getting a picture from the gallery............................................................................. 331
21.12 How to delete x.bal files or other files from a project ............................................. 331
21.13 Block a screen orientation ........................................................................................ 332
21.14 Close second Activity .............................................................................................. 333
21.15 Taking a screenshot programaticaly ......................................................................... 333
21.16 After compiling, where are the files ......................................................................... 333
21.17 Run an application from another one........................................................................ 334
21.18 How to pass an Array to a Sub ................................................................................. 334
21.19 Getting language and country from device ............................................................... 335
Table of contents 6 Basic4Android Beginner's Guide
22 Glossary .......................................................................................................................... 336
- 上一篇: Android 开发 API人脸检测实例教程
- 下一篇: 大数据面试宝典+简历模板