madshellnpm 2.0.0
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.
- package/cli.js +44 -0
- package/generator.js +30 -0
- package/index.js +5 -0
- package/menu/context menu/MainActivity.kt +50 -0
- package/menu/context menu/activity_main.xml +18 -0
- package/menu/context menu/menu_main.xml +34 -0
- package/menu/options menu/MainActivity.kt +52 -0
- package/menu/options menu/activity_main.xml +9 -0
- package/menu/options menu/menu_main.xml +81 -0
- package/menu/popup menu/MainActivity.kt +58 -0
- package/menu/popup menu/activity_main.xml +20 -0
- package/menu/popup menu/menu_main.xml +39 -0
- package/package.json +27 -0
- package/templates/alertdialog/MainActivity.kt +47 -0
- package/templates/alertdialog/activity_main.xml +39 -0
- package/templates/animations/MainActivity.kt +70 -0
- package/templates/animations/activity_main.xml +125 -0
- package/templates/animations/bounce.xml +24 -0
- package/templates/animations/fade_in.xml +11 -0
- package/templates/animations/fade_out.xml +12 -0
- package/templates/animations/slide_down.xml +9 -0
- package/templates/animations/slide_up.xml +9 -0
- package/templates/animations/zoom_in.xml +15 -0
- package/templates/animations/zoom_out.xml +15 -0
- package/templates/autocomplete_textview/MainActivity.kt +40 -0
- package/templates/autocomplete_textview/activity_main.xml +34 -0
- package/templates/canvas/MainActivity.kt +54 -0
- package/templates/canvas/activity_main.xml +19 -0
- package/templates/canvas/example2.kt +13 -0
- package/templates/checkbox/MainActivity.kt +56 -0
- package/templates/checkbox/activity_main.xml +67 -0
- package/templates/custom_checkbox/MainActivity.kt +32 -0
- package/templates/custom_checkbox/activity_main.xml +43 -0
- package/templates/custom_toast/MainActivity.kt +23 -0
- package/templates/custom_toast/activity_main.xml +22 -0
- package/templates/custom_toast/customtoast.xml +20 -0
- package/templates/database/MainActivity.kt +64 -0
- package/templates/database/activity_main.xml +77 -0
- package/templates/database/dbController.kt +56 -0
- package/templates/datepicker_and_timepicker/datepicker/MainActivity.kt +34 -0
- package/templates/datepicker_and_timepicker/datepicker/activity_main.xml +24 -0
- package/templates/datepicker_and_timepicker/timepicker/MainActivity.kt +37 -0
- package/templates/datepicker_and_timepicker/timepicker/activity_main.xml +15 -0
- package/templates/explicit_and_implicit_intents/example 1/MainActivity.kt +36 -0
- package/templates/explicit_and_implicit_intents/example 1/SecondActivity.kt +12 -0
- package/templates/explicit_and_implicit_intents/example 1/activity_main.xml +33 -0
- package/templates/explicit_and_implicit_intents/example 1/activity_second.xml +20 -0
- package/templates/explicit_and_implicit_intents/example 2/MainActivity.kt +37 -0
- package/templates/explicit_and_implicit_intents/example 2/MainActivity2.kt +23 -0
- package/templates/explicit_and_implicit_intents/example 2/activity_main.xml +38 -0
- package/templates/explicit_and_implicit_intents/example 2/activity_second.xml +18 -0
- package/templates/image_view_listener/MainActivity.kt +38 -0
- package/templates/image_view_listener/activity_main.xml +89 -0
- package/templates/menu/context menu/MainActivity.kt +50 -0
- package/templates/menu/context menu/activity_main.xml +18 -0
- package/templates/menu/context menu/menu_main.xml +34 -0
- package/templates/menu/options menu/MainActivity.kt +52 -0
- package/templates/menu/options menu/activity_main.xml +9 -0
- package/templates/menu/options menu/menu_main.xml +81 -0
- package/templates/menu/popup menu/MainActivity.kt +58 -0
- package/templates/menu/popup menu/activity_main.xml +20 -0
- package/templates/menu/popup menu/menu_main.xml +39 -0
- package/templates/progressbar/MainActivity.kt +60 -0
- package/templates/progressbar/activity_main.xml +47 -0
- package/templates/radio_button/MainActivity.kt +46 -0
- package/templates/radio_button/activity_main.xml +86 -0
- package/templates/sharedpreferences/example1/MainActivity.kt +54 -0
- package/templates/sharedpreferences/example1/activity_main.xml +69 -0
- package/templates/sharedpreferences/example2/MainActivity.kt +45 -0
- package/templates/sharedpreferences/example2/activity_main.xml +48 -0
- package/templates/spinner/MainActivity.kt +54 -0
- package/templates/spinner/activity_main.xml +37 -0
- package/templates/spinner/strings.xml +13 -0
- package/templates/toggle_button/MainActivity.kt +39 -0
- package/templates/toggle_button/activity_main.xml +50 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<RelativeLayout
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
5
|
+
android:layout_width="match_parent"
|
|
6
|
+
android:layout_height="match_parent"
|
|
7
|
+
tools:context=".MainActivity">
|
|
8
|
+
|
|
9
|
+
<TextView
|
|
10
|
+
android:id="@+id/textView"
|
|
11
|
+
android:layout_width="match_parent"
|
|
12
|
+
android:layout_height="match_parent"
|
|
13
|
+
android:layout_above="@+id/linearLayout"
|
|
14
|
+
android:gravity="center"
|
|
15
|
+
android:text="Mobile Application Development"
|
|
16
|
+
android:textSize="32sp"
|
|
17
|
+
android:textColor="@color/teal_200"
|
|
18
|
+
android:textStyle="bold" />
|
|
19
|
+
|
|
20
|
+
<LinearLayout
|
|
21
|
+
android:id="@+id/linearLayout"
|
|
22
|
+
android:layout_width="match_parent"
|
|
23
|
+
android:layout_height="wrap_content"
|
|
24
|
+
android:layout_alignParentBottom="true"
|
|
25
|
+
android:orientation="vertical">
|
|
26
|
+
|
|
27
|
+
<LinearLayout
|
|
28
|
+
android:layout_width="match_parent"
|
|
29
|
+
android:layout_height="wrap_content"
|
|
30
|
+
android:orientation="horizontal"
|
|
31
|
+
android:weightSum="2">
|
|
32
|
+
|
|
33
|
+
<Button
|
|
34
|
+
android:id="@+id/fade_in"
|
|
35
|
+
android:layout_width="0dp"
|
|
36
|
+
android:layout_height="match_parent"
|
|
37
|
+
android:layout_weight="1"
|
|
38
|
+
android:text="Fade In"
|
|
39
|
+
android:textAllCaps="false" />
|
|
40
|
+
|
|
41
|
+
<Button
|
|
42
|
+
android:id="@+id/fade_out"
|
|
43
|
+
android:layout_width="0dp"
|
|
44
|
+
android:layout_height="match_parent"
|
|
45
|
+
android:layout_weight="1"
|
|
46
|
+
android:text="Fade Out"
|
|
47
|
+
android:textAllCaps="false" />
|
|
48
|
+
|
|
49
|
+
</LinearLayout>
|
|
50
|
+
|
|
51
|
+
<LinearLayout
|
|
52
|
+
android:layout_width="match_parent"
|
|
53
|
+
android:layout_height="wrap_content"
|
|
54
|
+
android:orientation="horizontal"
|
|
55
|
+
android:weightSum="2">
|
|
56
|
+
|
|
57
|
+
<Button
|
|
58
|
+
android:id="@+id/zoom_in"
|
|
59
|
+
android:layout_width="0dp"
|
|
60
|
+
android:layout_height="match_parent"
|
|
61
|
+
android:layout_weight="1"
|
|
62
|
+
android:text="Zoom In"
|
|
63
|
+
android:textAllCaps="false" />
|
|
64
|
+
|
|
65
|
+
<Button
|
|
66
|
+
android:id="@+id/zoom_out"
|
|
67
|
+
android:layout_width="0dp"
|
|
68
|
+
android:layout_height="match_parent"
|
|
69
|
+
android:layout_weight="1"
|
|
70
|
+
android:text="Zoom Out"
|
|
71
|
+
android:textAllCaps="false" />
|
|
72
|
+
|
|
73
|
+
</LinearLayout>
|
|
74
|
+
|
|
75
|
+
<LinearLayout
|
|
76
|
+
android:layout_width="match_parent"
|
|
77
|
+
android:layout_height="wrap_content"
|
|
78
|
+
android:orientation="horizontal"
|
|
79
|
+
android:weightSum="2">
|
|
80
|
+
|
|
81
|
+
<Button
|
|
82
|
+
android:id="@+id/slide_down"
|
|
83
|
+
android:layout_width="0dp"
|
|
84
|
+
android:layout_height="match_parent"
|
|
85
|
+
android:layout_weight="1"
|
|
86
|
+
android:text="Slide Down"
|
|
87
|
+
android:textAllCaps="false" />
|
|
88
|
+
|
|
89
|
+
<Button
|
|
90
|
+
android:id="@+id/slide_up"
|
|
91
|
+
android:layout_width="0dp"
|
|
92
|
+
android:layout_height="match_parent"
|
|
93
|
+
android:layout_weight="1"
|
|
94
|
+
android:text="Slide Up"
|
|
95
|
+
android:textAllCaps="false" />
|
|
96
|
+
|
|
97
|
+
</LinearLayout>
|
|
98
|
+
|
|
99
|
+
<LinearLayout
|
|
100
|
+
android:layout_width="match_parent"
|
|
101
|
+
android:layout_height="wrap_content"
|
|
102
|
+
android:orientation="horizontal"
|
|
103
|
+
android:weightSum="2">
|
|
104
|
+
|
|
105
|
+
<Button
|
|
106
|
+
android:id="@+id/bounce"
|
|
107
|
+
android:layout_width="0dp"
|
|
108
|
+
android:layout_height="match_parent"
|
|
109
|
+
android:layout_weight="1"
|
|
110
|
+
android:text="Bounce"
|
|
111
|
+
android:textAllCaps="false" />
|
|
112
|
+
|
|
113
|
+
<Button
|
|
114
|
+
android:id="@+id/rotate"
|
|
115
|
+
android:layout_width="0dp"
|
|
116
|
+
android:layout_height="match_parent"
|
|
117
|
+
android:layout_weight="1"
|
|
118
|
+
android:text="Rotate"
|
|
119
|
+
android:textAllCaps="false" />
|
|
120
|
+
|
|
121
|
+
</LinearLayout>
|
|
122
|
+
|
|
123
|
+
</LinearLayout>
|
|
124
|
+
|
|
125
|
+
</RelativeLayout>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<set
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:interpolator="@android:anim/linear_interpolator"
|
|
5
|
+
android:fillAfter="true">
|
|
6
|
+
|
|
7
|
+
<translate
|
|
8
|
+
android:fromYDelta="100%"
|
|
9
|
+
android:toYDelta="-20%"
|
|
10
|
+
android:duration="300" />
|
|
11
|
+
|
|
12
|
+
<translate
|
|
13
|
+
android:startOffset="500"
|
|
14
|
+
android:fromYDelta="-20%"
|
|
15
|
+
android:toYDelta="10%"
|
|
16
|
+
android:duration="150" />
|
|
17
|
+
|
|
18
|
+
<translate
|
|
19
|
+
android:startOffset="1000"
|
|
20
|
+
android:fromYDelta="10%"
|
|
21
|
+
android:toYDelta="0"
|
|
22
|
+
android:duration="100" />
|
|
23
|
+
|
|
24
|
+
</set>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<set
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:interpolator="@android:anim/linear_interpolator">
|
|
5
|
+
|
|
6
|
+
<alpha
|
|
7
|
+
android:duration="1000"
|
|
8
|
+
android:fromAlpha="0.1"
|
|
9
|
+
android:toAlpha="1.0" />
|
|
10
|
+
|
|
11
|
+
</set>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<set
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:interpolator="@android:anim/linear_interpolator">
|
|
5
|
+
|
|
6
|
+
<alpha
|
|
7
|
+
android:duration="2000"
|
|
8
|
+
android:fillAfter="true"
|
|
9
|
+
android:fromAlpha="1.0"
|
|
10
|
+
android:toAlpha="0.1" />
|
|
11
|
+
|
|
12
|
+
</set>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<set
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:fillAfter="true">
|
|
5
|
+
|
|
6
|
+
<scale
|
|
7
|
+
android:duration="1000"
|
|
8
|
+
android:fromXScale="1"
|
|
9
|
+
android:fromYScale="1"
|
|
10
|
+
android:pivotX="50%"
|
|
11
|
+
android:pivotY="50%"
|
|
12
|
+
android:toXScale="1.5"
|
|
13
|
+
android:toYScale="1.5" />
|
|
14
|
+
|
|
15
|
+
</set>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<set
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:fillAfter="true">
|
|
5
|
+
|
|
6
|
+
<scale
|
|
7
|
+
android:duration="1000"
|
|
8
|
+
android:fromXScale="1.0"
|
|
9
|
+
android:fromYScale="1.0"
|
|
10
|
+
android:pivotX="50%"
|
|
11
|
+
android:pivotY="50%"
|
|
12
|
+
android:toXScale="0.5"
|
|
13
|
+
android:toYScale="0.5" />
|
|
14
|
+
|
|
15
|
+
</set>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.example.autocompletetextview
|
|
2
|
+
|
|
3
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.widget.ArrayAdapter
|
|
6
|
+
import android.widget.AutoCompleteTextView
|
|
7
|
+
|
|
8
|
+
class MainActivity : AppCompatActivity() {
|
|
9
|
+
|
|
10
|
+
private val fruits = arrayOf(
|
|
11
|
+
"Apple",
|
|
12
|
+
"Banana",
|
|
13
|
+
"Cherry",
|
|
14
|
+
"Date",
|
|
15
|
+
"Grape",
|
|
16
|
+
"Kiwi",
|
|
17
|
+
"Mango",
|
|
18
|
+
"Pear"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
22
|
+
super.onCreate(savedInstanceState)
|
|
23
|
+
setContentView(R.layout.activity_main)
|
|
24
|
+
|
|
25
|
+
title = "KotlinApp"
|
|
26
|
+
|
|
27
|
+
val autoTextView: AutoCompleteTextView =
|
|
28
|
+
findViewById(R.id.text)
|
|
29
|
+
|
|
30
|
+
val adapter: ArrayAdapter<String> =
|
|
31
|
+
ArrayAdapter(
|
|
32
|
+
this,
|
|
33
|
+
android.R.layout.select_dialog_item,
|
|
34
|
+
fruits
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
autoTextView.threshold = 1
|
|
38
|
+
autoTextView.setAdapter(adapter)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
|
|
3
|
+
<RelativeLayout
|
|
4
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
5
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
6
|
+
android:id="@+id/relativeLayout"
|
|
7
|
+
android:layout_width="match_parent"
|
|
8
|
+
android:layout_height="match_parent"
|
|
9
|
+
tools:context=".MainActivity">
|
|
10
|
+
|
|
11
|
+
<TextView
|
|
12
|
+
android:id="@+id/text2"
|
|
13
|
+
android:layout_width="wrap_content"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:layout_centerHorizontal="true"
|
|
16
|
+
android:layout_marginTop="70dp"
|
|
17
|
+
android:background="#008080"
|
|
18
|
+
android:padding="5dp"
|
|
19
|
+
android:text="MAD LAB AUTOTEXTVIEW"
|
|
20
|
+
android:textColor="#ffffff"
|
|
21
|
+
android:textSize="24sp"
|
|
22
|
+
android:textStyle="bold" />
|
|
23
|
+
|
|
24
|
+
<AutoCompleteTextView
|
|
25
|
+
android:id="@+id/text"
|
|
26
|
+
android:layout_width="match_parent"
|
|
27
|
+
android:layout_height="wrap_content"
|
|
28
|
+
android:layout_below="@id/text2"
|
|
29
|
+
android:layout_marginTop="20dp"
|
|
30
|
+
android:hint="Enter fruit name"
|
|
31
|
+
android:textColor="@android:color/background_dark"
|
|
32
|
+
android:textStyle="bold" />
|
|
33
|
+
|
|
34
|
+
</RelativeLayout>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.example.canvas
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap
|
|
4
|
+
import android.graphics.Canvas
|
|
5
|
+
import android.graphics.Color
|
|
6
|
+
import android.graphics.drawable.BitmapDrawable
|
|
7
|
+
import android.graphics.drawable.ShapeDrawable
|
|
8
|
+
import android.graphics.drawable.shapes.OvalShape
|
|
9
|
+
import android.graphics.drawable.shapes.RectShape
|
|
10
|
+
import android.support.v7.app.AppCompatActivity
|
|
11
|
+
import android.os.Bundle
|
|
12
|
+
import android.widget.ImageView
|
|
13
|
+
|
|
14
|
+
class MainActivity : AppCompatActivity() {
|
|
15
|
+
|
|
16
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
17
|
+
super.onCreate(savedInstanceState)
|
|
18
|
+
setContentView(R.layout.activity_main)
|
|
19
|
+
|
|
20
|
+
val bitmap: Bitmap = Bitmap.createBitmap(
|
|
21
|
+
700,
|
|
22
|
+
1000,
|
|
23
|
+
Bitmap.Config.ARGB_8888
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
val canvas: Canvas = Canvas(bitmap)
|
|
27
|
+
|
|
28
|
+
var shapeDrawable: ShapeDrawable
|
|
29
|
+
|
|
30
|
+
// rectangle positions
|
|
31
|
+
var left = 100
|
|
32
|
+
var top = 100
|
|
33
|
+
var right = 600
|
|
34
|
+
var bottom = 400
|
|
35
|
+
|
|
36
|
+
// draw rectangle shape to canvas
|
|
37
|
+
shapeDrawable = ShapeDrawable(RectShape())
|
|
38
|
+
shapeDrawable.setBounds(left, top, right, bottom)
|
|
39
|
+
shapeDrawable.paint.setColor(Color.parseColor("#009944"))
|
|
40
|
+
shapeDrawable.draw(canvas)
|
|
41
|
+
|
|
42
|
+
// draw oval shape to canvas
|
|
43
|
+
shapeDrawable = ShapeDrawable(OvalShape())
|
|
44
|
+
shapeDrawable.setBounds(100, 500, 600, 800)
|
|
45
|
+
shapeDrawable.getPaint().setColor(Color.parseColor("#009944"))
|
|
46
|
+
shapeDrawable.draw(canvas)
|
|
47
|
+
|
|
48
|
+
val iv = findViewById<ImageView>(R.id.imageV)
|
|
49
|
+
|
|
50
|
+
// now bitmap holds the updated pixels
|
|
51
|
+
// set bitmap as background to ImageView
|
|
52
|
+
iv.background = BitmapDrawable(getResources(), bitmap)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
5
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
6
|
+
android:layout_width="match_parent"
|
|
7
|
+
android:layout_height="match_parent"
|
|
8
|
+
tools:context=".MainActivity">
|
|
9
|
+
|
|
10
|
+
<ImageView
|
|
11
|
+
android:id="@+id/imageV"
|
|
12
|
+
android:layout_width="315dp"
|
|
13
|
+
android:layout_height="526dp"
|
|
14
|
+
android:layout_marginTop="100dp"
|
|
15
|
+
android:layout_marginEnd="50dp"
|
|
16
|
+
app:layout_constraintTop_toTopOf="parent"
|
|
17
|
+
app:layout_constraintEnd_toEndOf="parent" />
|
|
18
|
+
|
|
19
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package com.example.checkbox
|
|
2
|
+
|
|
3
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.widget.Button
|
|
6
|
+
import android.widget.CheckBox
|
|
7
|
+
import android.widget.Toast
|
|
8
|
+
|
|
9
|
+
class MainActivity : AppCompatActivity() {
|
|
10
|
+
|
|
11
|
+
lateinit var pizza: CheckBox
|
|
12
|
+
lateinit var coffee: CheckBox
|
|
13
|
+
lateinit var burger: CheckBox
|
|
14
|
+
lateinit var button: Button
|
|
15
|
+
|
|
16
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
17
|
+
super.onCreate(savedInstanceState)
|
|
18
|
+
setContentView(R.layout.activity_main)
|
|
19
|
+
|
|
20
|
+
pizza = findViewById(R.id.checkBox1)
|
|
21
|
+
coffee = findViewById(R.id.checkBox2)
|
|
22
|
+
burger = findViewById(R.id.checkBox3)
|
|
23
|
+
button = findViewById(R.id.button)
|
|
24
|
+
|
|
25
|
+
button.setOnClickListener {
|
|
26
|
+
|
|
27
|
+
var totalAmount: Int = 0
|
|
28
|
+
val result = StringBuilder()
|
|
29
|
+
|
|
30
|
+
result.append("Selected Items")
|
|
31
|
+
|
|
32
|
+
if (pizza.isChecked) {
|
|
33
|
+
result.append("\nPizza 100Rs")
|
|
34
|
+
totalAmount += 100
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (coffee.isChecked) {
|
|
38
|
+
result.append("\nCoffee 50Rs")
|
|
39
|
+
totalAmount += 50
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (burger.isChecked) {
|
|
43
|
+
result.append("\nBurger 120Rs")
|
|
44
|
+
totalAmount += 120
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
result.append("\nTotal: $totalAmount Rs")
|
|
48
|
+
|
|
49
|
+
Toast.makeText(
|
|
50
|
+
applicationContext,
|
|
51
|
+
result.toString(),
|
|
52
|
+
Toast.LENGTH_SHORT
|
|
53
|
+
).show()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
|
|
3
|
+
<RelativeLayout
|
|
4
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
5
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
6
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
7
|
+
android:layout_width="match_parent"
|
|
8
|
+
android:layout_height="match_parent"
|
|
9
|
+
android:padding="16dp"
|
|
10
|
+
tools:context=".MainActivity">
|
|
11
|
+
|
|
12
|
+
<TextView
|
|
13
|
+
android:layout_width="wrap_content"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:layout_centerHorizontal="true"
|
|
16
|
+
android:layout_marginTop="50dp"
|
|
17
|
+
android:text="MAD LAB CHECK BOX EXAMPLE"
|
|
18
|
+
android:textAlignment="center"
|
|
19
|
+
android:textColor="@android:color/holo_green_dark"
|
|
20
|
+
android:textSize="32sp"
|
|
21
|
+
android:textStyle="bold" />
|
|
22
|
+
|
|
23
|
+
<TextView
|
|
24
|
+
android:layout_width="match_parent"
|
|
25
|
+
android:layout_height="wrap_content"
|
|
26
|
+
android:layout_above="@id/checkBox1"
|
|
27
|
+
android:layout_marginBottom="50dp"
|
|
28
|
+
android:text="Select your products!!"
|
|
29
|
+
android:textAlignment="center"
|
|
30
|
+
android:textColor="@android:color/background_dark"
|
|
31
|
+
android:textSize="24sp"
|
|
32
|
+
android:textStyle="bold|italic" />
|
|
33
|
+
|
|
34
|
+
<CheckBox
|
|
35
|
+
android:id="@+id/checkBox1"
|
|
36
|
+
android:layout_width="wrap_content"
|
|
37
|
+
android:layout_height="wrap_content"
|
|
38
|
+
android:layout_centerInParent="true"
|
|
39
|
+
android:text="Pizza" />
|
|
40
|
+
|
|
41
|
+
<CheckBox
|
|
42
|
+
android:id="@+id/checkBox2"
|
|
43
|
+
android:layout_width="wrap_content"
|
|
44
|
+
android:layout_height="wrap_content"
|
|
45
|
+
android:layout_below="@id/checkBox1"
|
|
46
|
+
android:layout_centerInParent="true"
|
|
47
|
+
android:layout_marginTop="10dp"
|
|
48
|
+
android:text="Coffee" />
|
|
49
|
+
|
|
50
|
+
<CheckBox
|
|
51
|
+
android:id="@+id/checkBox3"
|
|
52
|
+
android:layout_width="wrap_content"
|
|
53
|
+
android:layout_height="wrap_content"
|
|
54
|
+
android:layout_below="@id/checkBox2"
|
|
55
|
+
android:layout_centerInParent="true"
|
|
56
|
+
android:layout_marginTop="10dp"
|
|
57
|
+
android:text="Burger" />
|
|
58
|
+
|
|
59
|
+
<Button
|
|
60
|
+
android:id="@+id/button"
|
|
61
|
+
android:layout_width="match_parent"
|
|
62
|
+
android:layout_height="wrap_content"
|
|
63
|
+
android:layout_below="@id/checkBox3"
|
|
64
|
+
android:layout_marginTop="10dp"
|
|
65
|
+
android:text="Complete purchase" />
|
|
66
|
+
|
|
67
|
+
</RelativeLayout>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.example.customcheckbox
|
|
2
|
+
|
|
3
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.widget.Button
|
|
6
|
+
import android.widget.CheckBox
|
|
7
|
+
import android.widget.Toast
|
|
8
|
+
|
|
9
|
+
class MainActivity : AppCompatActivity() {
|
|
10
|
+
|
|
11
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
12
|
+
super.onCreate(savedInstanceState)
|
|
13
|
+
setContentView(R.layout.activity_main)
|
|
14
|
+
|
|
15
|
+
val btn = findViewById<Button>(R.id.button1)
|
|
16
|
+
|
|
17
|
+
btn.setOnClickListener {
|
|
18
|
+
val ckb3 = findViewById<CheckBox>(R.id.checkBox3)
|
|
19
|
+
val ckb4 = findViewById<CheckBox>(R.id.checkBox4)
|
|
20
|
+
|
|
21
|
+
val sb = StringBuilder()
|
|
22
|
+
|
|
23
|
+
if (ckb3.isChecked)
|
|
24
|
+
sb.append(" ${ckb3.text}")
|
|
25
|
+
|
|
26
|
+
if (ckb4.isChecked)
|
|
27
|
+
sb.append(" ${ckb4.text}")
|
|
28
|
+
|
|
29
|
+
Toast.makeText(this, sb.toString(), Toast.LENGTH_LONG).show()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
5
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
6
|
+
android:layout_width="match_parent"
|
|
7
|
+
android:layout_height="match_parent"
|
|
8
|
+
tools:context=".MainActivity">
|
|
9
|
+
|
|
10
|
+
<CheckBox
|
|
11
|
+
android:id="@+id/checkBox3"
|
|
12
|
+
android:layout_width="wrap_content"
|
|
13
|
+
android:layout_height="wrap_content"
|
|
14
|
+
android:button="@drawable/ic_launcher_foreground"
|
|
15
|
+
android:checked="true"
|
|
16
|
+
android:text="CheckBox3"
|
|
17
|
+
app:layout_constraintTop_toTopOf="parent"
|
|
18
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
19
|
+
app:layout_constraintEnd_toEndOf="parent" />
|
|
20
|
+
|
|
21
|
+
<CheckBox
|
|
22
|
+
android:id="@+id/checkBox4"
|
|
23
|
+
android:layout_width="wrap_content"
|
|
24
|
+
android:layout_height="wrap_content"
|
|
25
|
+
android:layout_marginTop="104dp"
|
|
26
|
+
android:button="@drawable/star"
|
|
27
|
+
android:checked="false"
|
|
28
|
+
android:text="CheckBox4"
|
|
29
|
+
app:layout_constraintTop_toBottomOf="@id/checkBox3"
|
|
30
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
31
|
+
app:layout_constraintEnd_toEndOf="parent" />
|
|
32
|
+
|
|
33
|
+
<Button
|
|
34
|
+
android:id="@+id/button1"
|
|
35
|
+
android:layout_width="wrap_content"
|
|
36
|
+
android:layout_height="wrap_content"
|
|
37
|
+
android:text="Show Selected"
|
|
38
|
+
app:layout_constraintTop_toBottomOf="@id/checkBox4"
|
|
39
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
|
40
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
41
|
+
app:layout_constraintEnd_toEndOf="parent" />
|
|
42
|
+
|
|
43
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class MainActivity : AppCompatActivity() {
|
|
2
|
+
|
|
3
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
4
|
+
super.onCreate(savedInstanceState)
|
|
5
|
+
setContentView(R.layout.activity_main)
|
|
6
|
+
|
|
7
|
+
val b1 = findViewById<Button>(R.id.buttonShowToast)
|
|
8
|
+
|
|
9
|
+
b1.setOnClickListener {
|
|
10
|
+
|
|
11
|
+
val ctoastlayout = layoutInflater.inflate(
|
|
12
|
+
R.layout.customtoast,
|
|
13
|
+
findViewById(R.id.customcontainer)
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
val customToast = Toast(this)
|
|
17
|
+
customToast.view = ctoastlayout
|
|
18
|
+
customToast.setGravity(Gravity.CENTER, 0, 0)
|
|
19
|
+
customToast.duration = Toast.LENGTH_LONG
|
|
20
|
+
customToast.show()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
5
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
6
|
+
android:layout_width="match_parent"
|
|
7
|
+
android:layout_height="match_parent"
|
|
8
|
+
tools:context=".MainActivity">
|
|
9
|
+
|
|
10
|
+
<Button
|
|
11
|
+
android:id="@+id/buttonShowToast"
|
|
12
|
+
android:layout_width="match_parent"
|
|
13
|
+
android:layout_height="wrap_content"
|
|
14
|
+
android:backgroundTint="#03A9F4"
|
|
15
|
+
android:text="Show Custom Toast"
|
|
16
|
+
android:textColor="#FFFFFF"
|
|
17
|
+
app:layout_constraintTop_toTopOf="parent"
|
|
18
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
|
19
|
+
app:layout_constraintVertical_bias="0.759"
|
|
20
|
+
tools:layout_editor_absoluteX="0dp" />
|
|
21
|
+
|
|
22
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<LinearLayout
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:id="@+id/customcontainer"
|
|
5
|
+
android:orientation="horizontal"
|
|
6
|
+
android:layout_width="match_parent"
|
|
7
|
+
android:layout_height="match_parent">
|
|
8
|
+
|
|
9
|
+
<ImageView
|
|
10
|
+
android:layout_width="50dp"
|
|
11
|
+
android:layout_height="50dp"
|
|
12
|
+
android:src="@drawable/smile" />
|
|
13
|
+
|
|
14
|
+
<TextView
|
|
15
|
+
android:layout_width="wrap_content"
|
|
16
|
+
android:layout_height="wrap_content"
|
|
17
|
+
android:text="This is Custom Toast"
|
|
18
|
+
android:textSize="24sp" />
|
|
19
|
+
|
|
20
|
+
</LinearLayout>
|