androidd 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- androidd/__init__.py +1 -0
- androidd/cie1/activityCycle/MainActivity.kt +44 -0
- androidd/cie1/activityCycle/activity_main.xml +15 -0
- androidd/cie1/alert/MainActivity.kt +28 -0
- androidd/cie1/alert/activity_main.xml +14 -0
- androidd/cie1/autoCompleteText/MainActivity.kt +19 -0
- androidd/cie1/autoCompleteText/activity_main.xml +14 -0
- androidd/cie1/checkbox/MainActivity.kt +28 -0
- androidd/cie1/checkbox/activity_main.xml +32 -0
- androidd/cie1/customCheckbox/MainActivity.kt +20 -0
- androidd/cie1/customCheckbox/activity_main.xml +22 -0
- androidd/cie1/customCheckbox/custom_checkbox.xml +9 -0
- androidd/cie1/customRadio/MainActivity.kt +22 -0
- androidd/cie1/customRadio/activity_main.xml +28 -0
- androidd/cie1/customRadio/custom_checkbox.xml +9 -0
- androidd/cie1/customToast/MainActivity.kt +35 -0
- androidd/cie1/customToast/activity_main.xml +14 -0
- androidd/cie1/customToast/custom_toast.xml +23 -0
- androidd/cie1/datepicker/MainActivity.kt +31 -0
- androidd/cie1/datepicker/activity_main.xml +20 -0
- androidd/cie1/progressbar/MainActivity.kt +26 -0
- androidd/cie1/progressbar/activity_main.xml +21 -0
- androidd/cie1/radiobutton/MainActivity.kt +25 -0
- androidd/cie1/radiobutton/activity_main.xml +38 -0
- androidd/cie1/timePicker/MainActivity.kt +30 -0
- androidd/cie1/timePicker/activity_main.xml +20 -0
- androidd/cie1/toast/MainActivity.kt +18 -0
- androidd/cie1/toast/activity_main.xml +14 -0
- androidd/cie1/toggle/MainActivity.kt +20 -0
- androidd/cie1/toggle/activity_main.xml +23 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/Main Activity.kt +31 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/activity_main.xml +33 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/second.xml +16 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/secondactivity.kt +15 -0
- androidd/madbmsj/animation/MainActivity.kt +60 -0
- androidd/madbmsj/animation/activity_main.xml +122 -0
- androidd/madbmsj/animation/bounce.xml +17 -0
- androidd/madbmsj/animation/fad_in.xml +7 -0
- androidd/madbmsj/animation/fade_out.xml +8 -0
- androidd/madbmsj/animation/info.txt +2 -0
- androidd/madbmsj/animation/slide_down.xml +7 -0
- androidd/madbmsj/animation/slide_up.xml +7 -0
- androidd/madbmsj/animation/zoom_in.xml +11 -0
- androidd/madbmsj/animation/zoom_out.xml +11 -0
- androidd/madbmsj/canvas/MainActivity.kt +51 -0
- androidd/madbmsj/canvas/activity_main.xml +18 -0
- androidd/madbmsj/cie1/code.txt +719 -0
- androidd/madbmsj/cie1/sampleQuestion.txt +280 -0
- androidd/madbmsj/cie2/code.txt +1255 -0
- androidd/madbmsj/cie2/ques1/AndroidManifest.xml +2 -0
- androidd/madbmsj/cie2/ques1/MainActivity.kt +45 -0
- androidd/madbmsj/cie2/ques1/SecondActivity.kt +21 -0
- androidd/madbmsj/cie2/ques1/activity_main.xml +19 -0
- androidd/madbmsj/cie2/ques1/activity_second.xml +15 -0
- androidd/madbmsj/cie2/ques1/department_menu.xml +11 -0
- androidd/madbmsj/contextMenu/MainActivity.kt +37 -0
- androidd/madbmsj/contextMenu/activity_main.xml +19 -0
- androidd/madbmsj/contextMenu/info.txt +1 -0
- androidd/madbmsj/contextMenu/menu_main.xml +16 -0
- androidd/madbmsj/database/DatabaseHelper.kt +108 -0
- androidd/madbmsj/database/MainActivity.kt +151 -0
- androidd/madbmsj/database/activity_main.xml +55 -0
- androidd/madbmsj/database/dialog_update_student.xml +22 -0
- androidd/madbmsj/database/info.txt +4 -0
- androidd/madbmsj/datePicker/MainActivity.kt +23 -0
- androidd/madbmsj/datePicker/activity_main.xml +20 -0
- androidd/madbmsj/explicit/activity_main.xml +39 -0
- androidd/madbmsj/explicit/activity_second.xml +15 -0
- androidd/madbmsj/explicit/info.txt +6 -0
- androidd/madbmsj/explicit/mainactivity.kt +32 -0
- androidd/madbmsj/explicit/secondactivity.kt +27 -0
- androidd/madbmsj/fragment/MainActivity.kt +35 -0
- androidd/madbmsj/fragment/activity_main.xml +41 -0
- androidd/madbmsj/fragment/fragment_1.kt +24 -0
- androidd/madbmsj/fragment/fragment_1.xml +16 -0
- androidd/madbmsj/fragment/fragment_2.kt +17 -0
- androidd/madbmsj/fragment/fragnent_2.xml +16 -0
- androidd/madbmsj/fragment/info.txt +1 -0
- androidd/madbmsj/optionsMenu/MainActivity.kt +26 -0
- androidd/madbmsj/optionsMenu/activity_main.xml +18 -0
- androidd/madbmsj/optionsMenu/info.txt +1 -0
- androidd/madbmsj/optionsMenu/menu_main.xml +27 -0
- androidd/madbmsj/package.json +13 -0
- androidd/madbmsj/popMenu/MainActivity.kt +49 -0
- androidd/madbmsj/popMenu/activity_main.xml +19 -0
- androidd/madbmsj/popMenu/info.txt +1 -0
- androidd/madbmsj/popMenu/menu_main.xml +16 -0
- androidd/madbmsj/sharedpref/shared1/activity_main.xml +64 -0
- androidd/madbmsj/sharedpref/shared1/mainactivity.kt +47 -0
- androidd/madbmsj/sharedpref/shared2/activity_main.xml +44 -0
- androidd/madbmsj/sharedpref/shared2/mainactivity.kt +57 -0
- {androidd-0.0.1.dist-info → androidd-0.0.2.dist-info}/METADATA +1 -1
- androidd-0.0.2.dist-info/RECORD +95 -0
- androidd-0.0.2.dist-info/top_level.txt +1 -0
- androidd-0.0.1.dist-info/RECORD +0 -4
- androidd-0.0.1.dist-info/top_level.txt +0 -1
- {androidd-0.0.1.dist-info → androidd-0.0.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,719 @@
|
|
1
|
+
package com.example.a1_activity_lifecycle
|
2
|
+
|
3
|
+
import android.support.v7.app.AppCompatActivity
|
4
|
+
import android.os.Bundle
|
5
|
+
import android.util.Log
|
6
|
+
|
7
|
+
class MainActivity : AppCompatActivity() {
|
8
|
+
|
9
|
+
val tag = "ActivityLifecycle"
|
10
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
11
|
+
super.onCreate(savedInstanceState)
|
12
|
+
setContentView(R.layout.activity_main)
|
13
|
+
Log.d(tag, "On Create Called")
|
14
|
+
}
|
15
|
+
|
16
|
+
override fun onStart() {
|
17
|
+
super.onStart()
|
18
|
+
Log.d(tag, "On Start Called")
|
19
|
+
}
|
20
|
+
|
21
|
+
override fun onResume() {
|
22
|
+
super.onResume()
|
23
|
+
Log.d(tag, "On Resume Called")
|
24
|
+
}
|
25
|
+
|
26
|
+
override fun onPause(){
|
27
|
+
super.onPause()
|
28
|
+
Log.d(tag,"OnPause Called")
|
29
|
+
|
30
|
+
}
|
31
|
+
|
32
|
+
override fun onDestroy() {
|
33
|
+
super.onDestroy()
|
34
|
+
Log.d(tag,"Ondestroy Called")
|
35
|
+
}
|
36
|
+
|
37
|
+
override fun onStop() {
|
38
|
+
super.onStop()
|
39
|
+
Log.d(tag,"OnStop Called")
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
<?xml version="1.0" encoding="utf-8"?>
|
47
|
+
<LinearLayout
|
48
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
49
|
+
android:layout_width="match_parent"
|
50
|
+
android:layout_height="match_parent"
|
51
|
+
android:orientation="vertical"
|
52
|
+
android:gravity="center"
|
53
|
+
>
|
54
|
+
|
55
|
+
<TextView
|
56
|
+
android:layout_width="wrap_content"
|
57
|
+
android:layout_height="wrap_content"
|
58
|
+
android:text="Lifecycle Example"
|
59
|
+
android:textSize="24sp"
|
60
|
+
android:textColor="@android:color/holo_blue_dark"></TextView>
|
61
|
+
|
62
|
+
</LinearLayout>
|
63
|
+
|
64
|
+
Widgets are the UI elements you use in Android apps. Examples include:
|
65
|
+
TextView – to display text
|
66
|
+
|
67
|
+
|
68
|
+
EditText – for user input
|
69
|
+
|
70
|
+
|
71
|
+
Button – to perform an action
|
72
|
+
|
73
|
+
|
74
|
+
ImageView, CheckBox, RadioButton, etc.
|
75
|
+
|
76
|
+
|
77
|
+
UI development means placing these widgets inside layout containers like LinearLayout, RelativeLayout, or ConstraintLayout to build screens.
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
package com.example.a3_android_widgets
|
84
|
+
|
85
|
+
import android.support.v7.app.AppCompatActivity
|
86
|
+
import android.os.Bundle
|
87
|
+
import android.widget.*
|
88
|
+
|
89
|
+
class MainActivity : AppCompatActivity() {
|
90
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
91
|
+
super.onCreate(savedInstanceState)
|
92
|
+
setContentView(R.layout.activity_main)
|
93
|
+
|
94
|
+
val inputName= findViewById<EditText>(R.id.editTextName)
|
95
|
+
val showButton=findViewById<Button>(R.id.buttonShow)
|
96
|
+
val resultText=findViewById<TextView>(R.id.textViewResult)
|
97
|
+
|
98
|
+
showButton.setOnClickListener{
|
99
|
+
val name= inputName.text.toString()
|
100
|
+
resultText.text="Hello,$name!"
|
101
|
+
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
<?xml version="1.0" encoding="utf-8"?>
|
108
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
109
|
+
android:layout_width="match_parent"
|
110
|
+
android:layout_height="match_parent"
|
111
|
+
android:padding="16dp"
|
112
|
+
android:orientation="vertical"
|
113
|
+
android:gravity="center"
|
114
|
+
>
|
115
|
+
|
116
|
+
<TextView
|
117
|
+
android:id="@+id/textViewResult"
|
118
|
+
android:layout_width="wrap_content"
|
119
|
+
android:layout_height="wrap_content"
|
120
|
+
android:text="Enter your name below:"
|
121
|
+
android:textSize="18sp"
|
122
|
+
/>
|
123
|
+
|
124
|
+
<EditText
|
125
|
+
android:id="@+id/editTextName"
|
126
|
+
android:layout_width="match_parent"
|
127
|
+
android:layout_height="wrap_content"
|
128
|
+
android:hint="Type your name" />
|
129
|
+
|
130
|
+
<Button
|
131
|
+
android:id="@+id/buttonShow"
|
132
|
+
android:layout_width="wrap_content"
|
133
|
+
android:layout_height="wrap_content"
|
134
|
+
android:text="Say Hello"
|
135
|
+
android:layout_marginTop="16dp" />
|
136
|
+
|
137
|
+
|
138
|
+
</LinearLayout>
|
139
|
+
|
140
|
+
package com.example.a5_workingwithbuttons
|
141
|
+
|
142
|
+
import android.support.v7.app.AppCompatActivity
|
143
|
+
import android.os.Bundle
|
144
|
+
import android.widget.*
|
145
|
+
|
146
|
+
class MainActivity : AppCompatActivity() {
|
147
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
148
|
+
super.onCreate(savedInstanceState)
|
149
|
+
setContentView(R.layout.activity_main)
|
150
|
+
|
151
|
+
val myButton=findViewById<Button>(R.id.mybutton)
|
152
|
+
val myTextView=findViewById<TextView>(R.id.mytextview)
|
153
|
+
|
154
|
+
myButton.setOnClickListener{
|
155
|
+
myTextView.text= "Button Clicked!"
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
|
161
|
+
<?xml version="1.0" encoding="utf-8"?>
|
162
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
163
|
+
android:layout_width="match_parent"
|
164
|
+
android:layout_height="match_parent"
|
165
|
+
android:padding="16dp"
|
166
|
+
android:orientation="vertical"
|
167
|
+
android:gravity="center"
|
168
|
+
>
|
169
|
+
|
170
|
+
<Button
|
171
|
+
android:id="@+id/mybutton"
|
172
|
+
android:layout_width="wrap_content"
|
173
|
+
android:layout_height="wrap_content"
|
174
|
+
android:text="Click Me"/>
|
175
|
+
|
176
|
+
<TextView
|
177
|
+
android:id="@+id/mytextview"
|
178
|
+
android:layout_width="wrap_content"
|
179
|
+
android:layout_height="wrap_content"
|
180
|
+
android:text=""
|
181
|
+
android:textSize="18sp"
|
182
|
+
android:layout_marginTop="20dp"
|
183
|
+
android:textColor="@android:color/holo_green_dark"
|
184
|
+
/>
|
185
|
+
|
186
|
+
</LinearLayout>
|
187
|
+
|
188
|
+
package com.example.myapplication(6th one,textview)
|
189
|
+
|
190
|
+
import android.support.v7.app.AppCompatActivity
|
191
|
+
import android.os.Bundle
|
192
|
+
import android.widget.TextView
|
193
|
+
|
194
|
+
class MainActivity : AppCompatActivity() {
|
195
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
196
|
+
super.onCreate(savedInstanceState)
|
197
|
+
setContentView(R.layout.activity_main)
|
198
|
+
|
199
|
+
val dynamicText = findViewById<TextView>(R.id.textDynamic)
|
200
|
+
|
201
|
+
// Change the text dynamically from code
|
202
|
+
dynamicText.text = "This text was set in Kotlin code!"
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
|
207
|
+
<?xml version="1.0" encoding="utf-8"?>
|
208
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
209
|
+
android:layout_width="match_parent"
|
210
|
+
android:layout_height="match_parent"
|
211
|
+
android:padding="16dp"
|
212
|
+
android:orientation="vertical"
|
213
|
+
android:gravity="center">
|
214
|
+
|
215
|
+
<TextView
|
216
|
+
android:id="@+id/textStatic"
|
217
|
+
android:layout_width="wrap_content"
|
218
|
+
android:layout_height="wrap_content"
|
219
|
+
android:text="Welcome to TextView Demo"
|
220
|
+
android:textSize="20sp"
|
221
|
+
android:textStyle="bold"
|
222
|
+
android:textColor="@android:color/holo_blue_dark"
|
223
|
+
android:layout_marginBottom="24dp"/>
|
224
|
+
|
225
|
+
<TextView
|
226
|
+
android:id="@+id/textDynamic"
|
227
|
+
android:layout_width="wrap_content"
|
228
|
+
android:layout_height="wrap_content"
|
229
|
+
android:text="Initial Text"
|
230
|
+
android:textSize="18sp"
|
231
|
+
android:textColor="@android:color/holo_green_dark"/>
|
232
|
+
</LinearLayout>
|
233
|
+
|
234
|
+
package com.example.a7_edittext
|
235
|
+
|
236
|
+
import android.support.v7.app.AppCompatActivity
|
237
|
+
import android.os.Bundle
|
238
|
+
import android.widget.*
|
239
|
+
|
240
|
+
class MainActivity : AppCompatActivity() {
|
241
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
242
|
+
super.onCreate(savedInstanceState)
|
243
|
+
setContentView(R.layout.activity_main)
|
244
|
+
|
245
|
+
val editTextName = findViewById<EditText>(R.id.editTextName)
|
246
|
+
val buttonShow = findViewById<Button>(R.id.buttonShow)
|
247
|
+
val textViewResult = findViewById<TextView>(R.id.textViewResult)
|
248
|
+
|
249
|
+
buttonShow.setOnClickListener {
|
250
|
+
val name = editTextName.text.toString()
|
251
|
+
textViewResult.text = "Hello, $name!"
|
252
|
+
}
|
253
|
+
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
<?xml version="1.0" encoding="utf-8"?>
|
259
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
260
|
+
android:layout_width="match_parent"
|
261
|
+
android:layout_height="match_parent"
|
262
|
+
android:orientation="vertical"
|
263
|
+
android:padding="16dp">
|
264
|
+
|
265
|
+
<EditText
|
266
|
+
android:id="@+id/editTextName"
|
267
|
+
android:layout_width="match_parent"
|
268
|
+
android:layout_height="wrap_content"
|
269
|
+
android:hint="Enter your name" />
|
270
|
+
|
271
|
+
<Button
|
272
|
+
android:id="@+id/buttonShow"
|
273
|
+
android:layout_width="wrap_content"
|
274
|
+
android:layout_height="wrap_content"
|
275
|
+
android:text="Show Name"
|
276
|
+
android:layout_marginTop="16dp" />
|
277
|
+
|
278
|
+
<TextView
|
279
|
+
android:id="@+id/textViewResult"
|
280
|
+
android:layout_width="wrap_content"
|
281
|
+
android:layout_height="wrap_content"
|
282
|
+
android:text="Your name will appear here"
|
283
|
+
android:layout_marginTop="16dp" />
|
284
|
+
</LinearLayout>
|
285
|
+
|
286
|
+
package com.example.a9_toast
|
287
|
+
|
288
|
+
import android.support.v7.app.AppCompatActivity
|
289
|
+
import android.os.Bundle
|
290
|
+
import android.widget.*
|
291
|
+
|
292
|
+
class MainActivity : AppCompatActivity() {
|
293
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
294
|
+
super.onCreate(savedInstanceState)
|
295
|
+
setContentView(R.layout.activity_main)
|
296
|
+
|
297
|
+
val buttonToast = findViewById<Button>(R.id.buttonShowToast)
|
298
|
+
|
299
|
+
buttonToast.setOnClickListener{
|
300
|
+
Toast.makeText(this,"Hello from toast", Toast.LENGTH_SHORT).show()
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
|
309
|
+
<?xml version="1.0" encoding="utf-8"?>
|
310
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
311
|
+
android:layout_width="match_parent"
|
312
|
+
android:layout_height="match_parent"
|
313
|
+
android:gravity="center"
|
314
|
+
android:orientation="vertical"
|
315
|
+
android:padding="24dp">
|
316
|
+
|
317
|
+
<Button
|
318
|
+
android:id="@+id/buttonShowToast"
|
319
|
+
android:layout_width="wrap_content"
|
320
|
+
android:layout_height="wrap_content"
|
321
|
+
android:text="Show Toast" />
|
322
|
+
</LinearLayout>
|
323
|
+
|
324
|
+
package com.example.a12_checkbox
|
325
|
+
|
326
|
+
import android.support.v7.app.AppCompatActivity
|
327
|
+
import android.os.Bundle
|
328
|
+
import android.widget.*
|
329
|
+
|
330
|
+
class MainActivity : AppCompatActivity() {
|
331
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
332
|
+
super.onCreate(savedInstanceState)
|
333
|
+
setContentView(R.layout.activity_main)
|
334
|
+
|
335
|
+
val checkbox = findViewById<CheckBox>(R.id.checkboxAndroid)
|
336
|
+
val button = findViewById<Button>(R.id.buttonCheck)
|
337
|
+
|
338
|
+
button.setOnClickListener {
|
339
|
+
if (checkbox.isChecked) {
|
340
|
+
Toast.makeText(this, "You love android", Toast.LENGTH_SHORT).show()
|
341
|
+
} else {
|
342
|
+
Toast.makeText(this,"You dont love android",Toast.LENGTH_SHORT).show()
|
343
|
+
}
|
344
|
+
}
|
345
|
+
}
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
<?xml version="1.0" encoding="utf-8"?>
|
350
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
351
|
+
android:layout_width="match_parent"
|
352
|
+
android:layout_height="match_parent"
|
353
|
+
android:orientation="vertical"
|
354
|
+
android:padding="16dp">
|
355
|
+
|
356
|
+
<CheckBox
|
357
|
+
android:id="@+id/checkboxAndroid"
|
358
|
+
android:layout_width="wrap_content"
|
359
|
+
android:layout_height="wrap_content"
|
360
|
+
android:text="I love Android" />
|
361
|
+
|
362
|
+
<Button
|
363
|
+
android:id="@+id/buttonCheck"
|
364
|
+
android:layout_width="wrap_content"
|
365
|
+
android:layout_height="wrap_content"
|
366
|
+
android:text="Check Status"
|
367
|
+
android:layout_marginTop="16dp" />
|
368
|
+
</LinearLayout>
|
369
|
+
|
370
|
+
package com.example.a13_customcheckbox
|
371
|
+
|
372
|
+
import android.support.v7.app.AppCompatActivity
|
373
|
+
import android.os.Bundle
|
374
|
+
import android.widget.*
|
375
|
+
|
376
|
+
class MainActivity : AppCompatActivity() {
|
377
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
378
|
+
super.onCreate(savedInstanceState)
|
379
|
+
setContentView(R.layout.activity_main)
|
380
|
+
|
381
|
+
val checkBox=findViewById<CheckBox>(R.id.customCheckbox)
|
382
|
+
|
383
|
+
checkBox.setOnCheckedChangeListener{_, isChecked ->
|
384
|
+
Toast.makeText(this,if(isChecked) "Checked" else "Unchecked", Toast.LENGTH_SHORT).show()
|
385
|
+
|
386
|
+
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
}
|
391
|
+
}
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
<?xml version="1.0" encoding="utf-8"?>
|
399
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
400
|
+
android:layout_width="match_parent"
|
401
|
+
android:layout_height="match_parent"
|
402
|
+
android:orientation="vertical"
|
403
|
+
android:padding="24dp">
|
404
|
+
|
405
|
+
<CheckBox
|
406
|
+
android:id="@+id/customCheckbox"
|
407
|
+
android:layout_width="326dp"
|
408
|
+
android:layout_height="399dp"
|
409
|
+
android:button="@drawable/custom_checkbox"
|
410
|
+
android:text="I agree to terms and conditions"
|
411
|
+
android:textSize="18sp" />
|
412
|
+
</LinearLayout>
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
custom_checkbox.xml
|
420
|
+
|
421
|
+
<?xml version="1.0" encoding="utf-8"?>
|
422
|
+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
423
|
+
<item android:drawable="@drawable/ic_baseline_star_24" android:state_checked="true" />
|
424
|
+
<item android:drawable="@drawable/ic_baseline_star_border_24" android:state_checked="false" />
|
425
|
+
</selector>
|
426
|
+
|
427
|
+
package com.example.a14_radio_button
|
428
|
+
|
429
|
+
import android.support.v7.app.AppCompatActivity
|
430
|
+
import android.os.Bundle
|
431
|
+
import android.widget.*
|
432
|
+
|
433
|
+
class MainActivity : AppCompatActivity() {
|
434
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
435
|
+
super.onCreate(savedInstanceState)
|
436
|
+
setContentView(R.layout.activity_main)
|
437
|
+
|
438
|
+
val radioGroup = findViewById<RadioGroup>(R.id.radioGroup)
|
439
|
+
val btnSubmit = findViewById<Button>(R.id.btn_submit)
|
440
|
+
|
441
|
+
btnSubmit.setOnClickListener {
|
442
|
+
val selectedId = radioGroup.checkedRadioButtonId
|
443
|
+
|
444
|
+
if (selectedId != -1) {
|
445
|
+
val selectedRadio = findViewById<RadioButton>(selectedId)
|
446
|
+
val gender = selectedRadio.text.toString()
|
447
|
+
Toast.makeText(this, "Selected: $gender", Toast.LENGTH_SHORT).show()
|
448
|
+
} else {
|
449
|
+
Toast.makeText(this, "Please select a gender", Toast.LENGTH_SHORT).show()
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
}
|
454
|
+
}
|
455
|
+
|
456
|
+
<?xml version="1.0" encoding="utf-8"?>
|
457
|
+
|
458
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
459
|
+
android:layout_width="match_parent"
|
460
|
+
android:layout_height="match_parent"
|
461
|
+
android:orientation="vertical"
|
462
|
+
android:padding="16dp">
|
463
|
+
|
464
|
+
<RadioGroup
|
465
|
+
android:id="@+id/radioGroup"
|
466
|
+
android:layout_width="wrap_content"
|
467
|
+
android:layout_height="wrap_content">
|
468
|
+
|
469
|
+
<RadioButton
|
470
|
+
android:id="@+id/radio_male"
|
471
|
+
android:layout_width="wrap_content"
|
472
|
+
android:layout_height="wrap_content"
|
473
|
+
android:text="Male" />
|
474
|
+
|
475
|
+
<RadioButton
|
476
|
+
android:id="@+id/radio_female"
|
477
|
+
android:layout_width="wrap_content"
|
478
|
+
android:layout_height="wrap_content"
|
479
|
+
android:text="Female" />
|
480
|
+
|
481
|
+
<RadioButton
|
482
|
+
android:id="@+id/radio_other"
|
483
|
+
android:layout_width="wrap_content"
|
484
|
+
android:layout_height="wrap_content"
|
485
|
+
android:text="Other" />
|
486
|
+
</RadioGroup>
|
487
|
+
|
488
|
+
<Button
|
489
|
+
android:id="@+id/btn_submit"
|
490
|
+
android:layout_width="wrap_content"
|
491
|
+
android:layout_height="wrap_content"
|
492
|
+
android:text="Submit" />
|
493
|
+
</LinearLayout>
|
494
|
+
|
495
|
+
package com.example.a171_custom_radiobutton
|
496
|
+
|
497
|
+
import android.support.v7.app.AppCompatActivity
|
498
|
+
import android.os.Bundle
|
499
|
+
import android.widget.RadioGroup
|
500
|
+
import android.widget.Toast
|
501
|
+
|
502
|
+
class MainActivity : AppCompatActivity() {
|
503
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
504
|
+
super.onCreate(savedInstanceState)
|
505
|
+
setContentView(R.layout.activity_main)
|
506
|
+
|
507
|
+
val radiogroup= findViewById<RadioGroup>(R.id.radioGroup)
|
508
|
+
|
509
|
+
radiogroup.setOnCheckedChangeListener{_,checkedId->
|
510
|
+
val selected=when(checkedId){
|
511
|
+
R.id.radio1->"I love Sweet!"
|
512
|
+
R.id.radio2->"I love Spicy!"
|
513
|
+
R.id.radio3->"I love Sour!"
|
514
|
+
else->""
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
}
|
519
|
+
Toast.makeText(this,"Selected: $selected",Toast.LENGTH_SHORT).show()
|
520
|
+
}
|
521
|
+
|
522
|
+
}
|
523
|
+
}
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
<?xml version="1.0" encoding="utf-8"?>
|
529
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
530
|
+
android:layout_width="match_parent"
|
531
|
+
android:layout_height="match_parent"
|
532
|
+
android:orientation="vertical"
|
533
|
+
android:padding="24dp">
|
534
|
+
|
535
|
+
<RadioGroup
|
536
|
+
android:id="@+id/radioGroup"
|
537
|
+
android:layout_width="wrap_content"
|
538
|
+
android:layout_height="wrap_content">
|
539
|
+
|
540
|
+
<RadioButton
|
541
|
+
android:id="@+id/radio1"
|
542
|
+
android:layout_width="wrap_content"
|
543
|
+
android:layout_height="wrap_content"
|
544
|
+
android:button="@drawable/custom_radio_selector"
|
545
|
+
android:text="I love Sweet!" />
|
546
|
+
|
547
|
+
<RadioButton
|
548
|
+
android:id="@+id/radio2"
|
549
|
+
android:layout_width="wrap_content"
|
550
|
+
android:layout_height="wrap_content"
|
551
|
+
android:button="@drawable/custom_radio_selector"
|
552
|
+
android:text="I love Spicy!" />
|
553
|
+
|
554
|
+
<RadioButton
|
555
|
+
android:id="@+id/radio3"
|
556
|
+
android:layout_width="wrap_content"
|
557
|
+
android:layout_height="wrap_content"
|
558
|
+
android:button="@drawable/custom_radio_selector"
|
559
|
+
android:text="I love Sour!" />
|
560
|
+
</RadioGroup>
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
</LinearLayout>
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
Custom radio selector
|
569
|
+
|
570
|
+
|
571
|
+
<?xml version="1.0" encoding="utf-8"?>
|
572
|
+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
573
|
+
<item android:drawable="@drawable/ic_baseline_favorite_24" android:state_checked="true" />
|
574
|
+
<item android:drawable="@drawable/ic_baseline_favorite_border_24" android:state_checked="false" />
|
575
|
+
|
576
|
+
</selector>
|
577
|
+
|
578
|
+
package com.example.a18_alert_dialogue
|
579
|
+
|
580
|
+
import android.content.DialogInterface
|
581
|
+
import android.os.Bundle
|
582
|
+
import android.support.v7.app.AlertDialog
|
583
|
+
import android.support.v7.app.AppCompatActivity
|
584
|
+
import android.widget.*
|
585
|
+
|
586
|
+
|
587
|
+
class MainActivity : AppCompatActivity() {
|
588
|
+
|
589
|
+
lateinit var btnShowDialog: Button
|
590
|
+
|
591
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
592
|
+
super.onCreate(savedInstanceState)
|
593
|
+
setContentView(R.layout.activity_main)
|
594
|
+
|
595
|
+
btnShowDialog = findViewById(R.id.btnShowDialog)
|
596
|
+
|
597
|
+
btnShowDialog.setOnClickListener {
|
598
|
+
showAlertDialog()
|
599
|
+
}
|
600
|
+
}
|
601
|
+
|
602
|
+
private fun showAlertDialog() {
|
603
|
+
val builder = AlertDialog.Builder(this)
|
604
|
+
builder.setTitle("Confirmation")
|
605
|
+
builder.setMessage("Do you want to continue?")
|
606
|
+
|
607
|
+
builder.setPositiveButton("Yes") { dialog, _ ->
|
608
|
+
Toast.makeText(this, "You clicked Yes", Toast.LENGTH_SHORT).show()
|
609
|
+
dialog.dismiss()
|
610
|
+
}
|
611
|
+
|
612
|
+
builder.setNegativeButton("No") { dialog, _ ->
|
613
|
+
Toast.makeText(this, "You clicked No", Toast.LENGTH_SHORT).show()
|
614
|
+
dialog.dismiss()
|
615
|
+
}
|
616
|
+
|
617
|
+
builder.setNeutralButton("Cancel") { dialog, _ ->
|
618
|
+
Toast.makeText(this, "You clicked Cancel", Toast.LENGTH_SHORT).show()
|
619
|
+
dialog.dismiss()
|
620
|
+
}
|
621
|
+
|
622
|
+
val dialog = builder.create()
|
623
|
+
dialog.show()
|
624
|
+
}
|
625
|
+
}
|
626
|
+
<?xml version="1.0" encoding="utf-8"?>
|
627
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
628
|
+
android:layout_width="match_parent"
|
629
|
+
android:layout_height="match_parent"
|
630
|
+
android:gravity="center"
|
631
|
+
android:orientation="vertical"
|
632
|
+
android:padding="16dp">
|
633
|
+
|
634
|
+
<Button
|
635
|
+
android:id="@+id/btnShowDialog"
|
636
|
+
android:layout_width="wrap_content"
|
637
|
+
android:layout_height="wrap_content"
|
638
|
+
android:text="Show Alert Dialog" />
|
639
|
+
</LinearLayout>
|
640
|
+
|
641
|
+
<?xml version="1.0" encoding="utf-8"?>
|
642
|
+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
643
|
+
android:layout_width="match_parent"
|
644
|
+
android:layout_height="match_parent"
|
645
|
+
android:padding="16dp">
|
646
|
+
|
647
|
+
<!-- Title TextView -->
|
648
|
+
<TextView
|
649
|
+
android:id="@+id/titleText"
|
650
|
+
android:layout_width="wrap_content"
|
651
|
+
android:layout_height="wrap_content"
|
652
|
+
android:text="You people are so petty and tiny!"
|
653
|
+
android:textSize="24sp"
|
654
|
+
android:textStyle="bold"
|
655
|
+
android:layout_centerHorizontal="true" />
|
656
|
+
|
657
|
+
<!-- Image below the title -->
|
658
|
+
<ImageView
|
659
|
+
android:id="@+id/logoImage"
|
660
|
+
android:layout_width="200dp"
|
661
|
+
android:layout_height="200dp"
|
662
|
+
android:src="@drawable/img"
|
663
|
+
android:adjustViewBounds="true"
|
664
|
+
android:contentDescription="Thor"
|
665
|
+
android:layout_below="@id/titleText"
|
666
|
+
android:layout_centerHorizontal="true"
|
667
|
+
android:layout_marginTop="20dp" />
|
668
|
+
|
669
|
+
<!-- Button to the left -->
|
670
|
+
<Button
|
671
|
+
android:id="@+id/leftButton"
|
672
|
+
android:layout_width="wrap_content"
|
673
|
+
android:layout_height="wrap_content"
|
674
|
+
android:layout_below="@id/logoImage"
|
675
|
+
android:layout_alignParentStart="true"
|
676
|
+
android:layout_marginTop="30dp"
|
677
|
+
android:text="You are a god of what?" />
|
678
|
+
|
679
|
+
<!-- Button to the right -->
|
680
|
+
<Button
|
681
|
+
android:id="@+id/rightButton"
|
682
|
+
android:layout_width="wrap_content"
|
683
|
+
android:layout_height="wrap_content"
|
684
|
+
android:text="I agree with you!"
|
685
|
+
android:layout_below="@id/logoImage"
|
686
|
+
android:layout_alignParentEnd="true"
|
687
|
+
android:layout_marginTop="30dp" />
|
688
|
+
|
689
|
+
</RelativeLayout>
|
690
|
+
|
691
|
+
package com.example.a22_relative_layout
|
692
|
+
|
693
|
+
import android.support.v7.app.AppCompatActivity
|
694
|
+
import android.os.Bundle
|
695
|
+
import android.widget.*
|
696
|
+
|
697
|
+
class MainActivity : AppCompatActivity() {
|
698
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
699
|
+
super.onCreate(savedInstanceState)
|
700
|
+
setContentView(R.layout.activity_main)
|
701
|
+
|
702
|
+
|
703
|
+
val leftButton=findViewById<Button>(R.id.leftButton)
|
704
|
+
val rightButton=findViewById<Button>(R.id.rightButton)
|
705
|
+
|
706
|
+
leftButton.setOnClickListener{
|
707
|
+
Toast.makeText(this,"Thunderrrrr!",Toast.LENGTH_SHORT).show()
|
708
|
+
}
|
709
|
+
|
710
|
+
rightButton.setOnClickListener{
|
711
|
+
Toast.makeText(this,"Because that's what heroes do!",Toast.LENGTH_SHORT).show()
|
712
|
+
}
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
}
|
717
|
+
}
|
718
|
+
|
719
|
+
|