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,64 @@
|
|
|
1
|
+
package com.example.dbsqlite
|
|
2
|
+
|
|
3
|
+
import android.support.v7.app.AppCompatActivity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.support.v7.app.AlertDialog
|
|
6
|
+
import android.view.View
|
|
7
|
+
import android.widget.EditText
|
|
8
|
+
import android.widget.TextView
|
|
9
|
+
import dbController.dbController
|
|
10
|
+
|
|
11
|
+
class MainActivity : AppCompatActivity() {
|
|
12
|
+
|
|
13
|
+
var fname: EditText? = null
|
|
14
|
+
var lname: EditText? = null
|
|
15
|
+
var list: TextView? = null
|
|
16
|
+
var dbc: dbController? = null // null values are allowed
|
|
17
|
+
|
|
18
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
19
|
+
super.onCreate(savedInstanceState)
|
|
20
|
+
setContentView(R.layout.activity_main)
|
|
21
|
+
|
|
22
|
+
fname = findViewById(R.id.fname)
|
|
23
|
+
lname = findViewById(R.id.lname)
|
|
24
|
+
list = findViewById(R.id.textView)
|
|
25
|
+
|
|
26
|
+
dbc = dbController(this, "", null, 1)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fun btn_click(v: View) {
|
|
30
|
+
when (v.id) {
|
|
31
|
+
|
|
32
|
+
R.id.btnadd ->
|
|
33
|
+
dbc?.insert(
|
|
34
|
+
fname!!.text.toString(),
|
|
35
|
+
lname!!.text.toString()
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
R.id.btndel ->
|
|
39
|
+
dbc?.delete(
|
|
40
|
+
fname!!.text.toString()
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
R.id.btnupd -> {
|
|
44
|
+
val dialog = AlertDialog.Builder(this@MainActivity)
|
|
45
|
+
dialog.setTitle("Enter Firstname")
|
|
46
|
+
|
|
47
|
+
val newFname = EditText(this)
|
|
48
|
+
dialog.setView(newFname)
|
|
49
|
+
|
|
50
|
+
dialog.setPositiveButton("OK") { dialog, which ->
|
|
51
|
+
dbc?.update(
|
|
52
|
+
fname!!.text.toString(),
|
|
53
|
+
newFname.text.toString()
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
dialog.show()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
R.id.btnlis ->
|
|
61
|
+
dbc?.list(list)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
<EditText
|
|
10
|
+
android:id="@+id/fname"
|
|
11
|
+
android:layout_width="match_parent"
|
|
12
|
+
android:layout_height="wrap_content"
|
|
13
|
+
android:layout_alignParentStart="true"
|
|
14
|
+
android:layout_alignParentLeft="true"
|
|
15
|
+
android:layout_alignParentTop="true"
|
|
16
|
+
android:ems="10"
|
|
17
|
+
android:hint="First Name"
|
|
18
|
+
android:inputType="textPersonName" />
|
|
19
|
+
|
|
20
|
+
<EditText
|
|
21
|
+
android:id="@+id/lname"
|
|
22
|
+
android:layout_width="match_parent"
|
|
23
|
+
android:layout_height="wrap_content"
|
|
24
|
+
android:layout_alignParentStart="true"
|
|
25
|
+
android:layout_alignParentLeft="true"
|
|
26
|
+
android:layout_below="@id/fname"
|
|
27
|
+
android:ems="10"
|
|
28
|
+
android:hint="Last Name"
|
|
29
|
+
android:inputType="textPersonName" />
|
|
30
|
+
|
|
31
|
+
<Button
|
|
32
|
+
android:id="@+id/btnadd"
|
|
33
|
+
android:layout_width="236dp"
|
|
34
|
+
android:layout_height="wrap_content"
|
|
35
|
+
android:layout_alignParentTop="true"
|
|
36
|
+
android:layout_centerHorizontal="true"
|
|
37
|
+
android:layout_marginTop="103dp"
|
|
38
|
+
android:onClick="btn_click"
|
|
39
|
+
android:text="Add Student" />
|
|
40
|
+
|
|
41
|
+
<Button
|
|
42
|
+
android:id="@+id/btndel"
|
|
43
|
+
android:layout_width="236dp"
|
|
44
|
+
android:layout_height="wrap_content"
|
|
45
|
+
android:layout_alignParentTop="true"
|
|
46
|
+
android:layout_centerHorizontal="true"
|
|
47
|
+
android:layout_marginTop="159dp"
|
|
48
|
+
android:onClick="btn_click"
|
|
49
|
+
android:text="Delete Student" />
|
|
50
|
+
|
|
51
|
+
<Button
|
|
52
|
+
android:id="@+id/btnupd"
|
|
53
|
+
android:layout_width="236dp"
|
|
54
|
+
android:layout_height="wrap_content"
|
|
55
|
+
android:layout_alignParentTop="true"
|
|
56
|
+
android:layout_centerHorizontal="true"
|
|
57
|
+
android:layout_marginTop="216dp"
|
|
58
|
+
android:onClick="btn_click"
|
|
59
|
+
android:text="Update Student" />
|
|
60
|
+
|
|
61
|
+
<Button
|
|
62
|
+
android:id="@+id/btnlis"
|
|
63
|
+
android:layout_width="236dp"
|
|
64
|
+
android:layout_height="wrap_content"
|
|
65
|
+
android:layout_below="@id/btnupd"
|
|
66
|
+
android:layout_centerHorizontal="true"
|
|
67
|
+
android:onClick="btn_click"
|
|
68
|
+
android:text="List Students" />
|
|
69
|
+
|
|
70
|
+
<TextView
|
|
71
|
+
android:id="@+id/textView"
|
|
72
|
+
android:layout_width="302dp"
|
|
73
|
+
android:layout_height="180dp"
|
|
74
|
+
android:layout_below="@id/btnlis"
|
|
75
|
+
android:layout_centerHorizontal="true" />
|
|
76
|
+
|
|
77
|
+
</RelativeLayout>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package dbController
|
|
2
|
+
|
|
3
|
+
import android.content.ContentValues
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.database.sqlite.SQLiteDatabase
|
|
6
|
+
import android.database.sqlite.SQLiteOpenHelper
|
|
7
|
+
import android.widget.TextView
|
|
8
|
+
|
|
9
|
+
class dbController(
|
|
10
|
+
context: Context,
|
|
11
|
+
name: String,
|
|
12
|
+
factory: SQLiteDatabase.CursorFactory?,
|
|
13
|
+
version: Int
|
|
14
|
+
) : SQLiteOpenHelper(context, "std.db", factory, version) {
|
|
15
|
+
|
|
16
|
+
override fun onCreate(db: SQLiteDatabase) {
|
|
17
|
+
db.execSQL("CREATE TABLE STUDENT(FNAME TEXT, LNAME TEXT);")
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun onUpgrade(db: SQLiteDatabase, i: Int, i1: Int) {
|
|
21
|
+
db.execSQL("DROP TABLE IF EXISTS STUDENT")
|
|
22
|
+
onCreate(db)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun insert(a: String, b: String) {
|
|
26
|
+
val cv = ContentValues()
|
|
27
|
+
cv.put("FNAME", a)
|
|
28
|
+
cv.put("LNAME", b)
|
|
29
|
+
|
|
30
|
+
this.writableDatabase.insert("STUDENT", null, cv)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fun delete(a: String) {
|
|
34
|
+
this.writableDatabase.delete("STUDENT", "FNAME='$a'", null)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun update(a: String, aa: String) {
|
|
38
|
+
this.writableDatabase.execSQL(
|
|
39
|
+
"UPDATE STUDENT SET FNAME='$aa' WHERE FNAME='$a';"
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fun list(tv: TextView?) {
|
|
44
|
+
|
|
45
|
+
tv?.text = ""
|
|
46
|
+
|
|
47
|
+
val c = this.readableDatabase.rawQuery(
|
|
48
|
+
"SELECT * FROM STUDENT",
|
|
49
|
+
null
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
while (c.moveToNext()) {
|
|
53
|
+
tv?.append("${c.getString(0)} ${c.getString(1)}\n")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.example.datepicker1
|
|
2
|
+
|
|
3
|
+
import android.os.Build
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.widget.DatePicker
|
|
6
|
+
import android.widget.Toast
|
|
7
|
+
import androidx.annotation.RequiresApi
|
|
8
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
9
|
+
import java.util.*
|
|
10
|
+
|
|
11
|
+
class MainActivity : AppCompatActivity() {
|
|
12
|
+
|
|
13
|
+
@RequiresApi(Build.VERSION_CODES.O)
|
|
14
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
15
|
+
|
|
16
|
+
super.onCreate(savedInstanceState)
|
|
17
|
+
setContentView(R.layout.activity_main)
|
|
18
|
+
|
|
19
|
+
val datePicker =
|
|
20
|
+
findViewById<DatePicker>(R.id.datePicker)
|
|
21
|
+
|
|
22
|
+
datePicker.setOnDateChangedListener {
|
|
23
|
+
datePicker, year, month, day ->
|
|
24
|
+
|
|
25
|
+
val monthValue = month + 1
|
|
26
|
+
|
|
27
|
+
Toast.makeText(
|
|
28
|
+
applicationContext,
|
|
29
|
+
"Date Is: $day/$monthValue/$year",
|
|
30
|
+
Toast.LENGTH_SHORT
|
|
31
|
+
).show()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
|
|
3
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
|
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
|
+
tools:context=".MainActivity">
|
|
10
|
+
|
|
11
|
+
<DatePicker
|
|
12
|
+
android:id="@+id/datePicker"
|
|
13
|
+
android:layout_width="wrap_content"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:layout_marginStart="30dp"
|
|
16
|
+
android:layout_marginTop="150dp"
|
|
17
|
+
android:layout_marginEnd="31dp"
|
|
18
|
+
android:layout_marginBottom="150dp"
|
|
19
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
|
20
|
+
app:layout_constraintEnd_toEndOf="parent"
|
|
21
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
22
|
+
app:layout_constraintTop_toTopOf="parent" />
|
|
23
|
+
|
|
24
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.example.timepicker1
|
|
2
|
+
|
|
3
|
+
import android.support.v7.app.AppCompatActivity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.widget.TimePicker
|
|
6
|
+
import android.widget.Toast
|
|
7
|
+
|
|
8
|
+
class MainActivity : AppCompatActivity() {
|
|
9
|
+
|
|
10
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
11
|
+
|
|
12
|
+
super.onCreate(savedInstanceState)
|
|
13
|
+
setContentView(R.layout.activity_main)
|
|
14
|
+
|
|
15
|
+
val timePicker =
|
|
16
|
+
findViewById<TimePicker>(R.id.timePicker)
|
|
17
|
+
|
|
18
|
+
timePicker.setOnTimeChangedListener { _, hour, minute ->
|
|
19
|
+
|
|
20
|
+
val am_pm = ""
|
|
21
|
+
|
|
22
|
+
val hourValue =
|
|
23
|
+
if (hour < 10) "0$hour" else hour
|
|
24
|
+
|
|
25
|
+
val min =
|
|
26
|
+
if (minute < 10) "0$minute" else minute
|
|
27
|
+
|
|
28
|
+
val msg = "Time is: $hourValue : $min $am_pm"
|
|
29
|
+
|
|
30
|
+
Toast.makeText(
|
|
31
|
+
this@MainActivity,
|
|
32
|
+
msg,
|
|
33
|
+
Toast.LENGTH_SHORT
|
|
34
|
+
).show()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
|
|
3
|
+
<RelativeLayout
|
|
4
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
5
|
+
android:layout_width="match_parent"
|
|
6
|
+
android:layout_height="match_parent">
|
|
7
|
+
|
|
8
|
+
<TimePicker
|
|
9
|
+
android:id="@+id/timePicker"
|
|
10
|
+
android:layout_width="wrap_content"
|
|
11
|
+
android:layout_height="wrap_content"
|
|
12
|
+
android:layout_centerHorizontal="true"
|
|
13
|
+
android:timePickerMode="spinner" />
|
|
14
|
+
|
|
15
|
+
</RelativeLayout>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.example.explicitintents
|
|
2
|
+
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import android.net.Uri
|
|
5
|
+
import android.support.v7.app.AppCompatActivity
|
|
6
|
+
import android.os.Bundle
|
|
7
|
+
import android.widget.Button
|
|
8
|
+
import android.widget.Toast
|
|
9
|
+
|
|
10
|
+
class MainActivity : AppCompatActivity() {
|
|
11
|
+
|
|
12
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
13
|
+
super.onCreate(savedInstanceState)
|
|
14
|
+
setContentView(R.layout.activity_main)
|
|
15
|
+
|
|
16
|
+
// Explicit Intent
|
|
17
|
+
val explicitButton = findViewById<Button>(R.id.ExplicitButton)
|
|
18
|
+
|
|
19
|
+
explicitButton.setOnClickListener {
|
|
20
|
+
Toast.makeText(this, "ExplicitIntent", Toast.LENGTH_SHORT).show()
|
|
21
|
+
|
|
22
|
+
val explicitIntent = Intent(this, SecondActivity::class.java)
|
|
23
|
+
startActivity(explicitIntent)
|
|
24
|
+
finish()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Implicit Intent
|
|
28
|
+
val url = "https://www.google.com"
|
|
29
|
+
val ib = findViewById<Button>(R.id.B1)
|
|
30
|
+
|
|
31
|
+
ib.setOnClickListener {
|
|
32
|
+
val implicitIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
|
33
|
+
startActivity(implicitIntent)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.example.explicitintents
|
|
2
|
+
|
|
3
|
+
import android.support.v7.app.AppCompatActivity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
|
|
6
|
+
class SecondActivity : AppCompatActivity() {
|
|
7
|
+
|
|
8
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
9
|
+
super.onCreate(savedInstanceState)
|
|
10
|
+
setContentView(R.layout.activity_second)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<android.support.constraint.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
|
+
<!-- Explicit Intent Button -->
|
|
11
|
+
<Button
|
|
12
|
+
android:id="@+id/ExplicitButton"
|
|
13
|
+
android:layout_width="wrap_content"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:layout_marginTop="88dp"
|
|
16
|
+
android:text="Explicit Intents"
|
|
17
|
+
android:textAllCaps="true"
|
|
18
|
+
app:layout_constraintTop_toTopOf="parent"
|
|
19
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
20
|
+
app:layout_constraintEnd_toEndOf="parent" />
|
|
21
|
+
|
|
22
|
+
<!-- Implicit Intent Button -->
|
|
23
|
+
<Button
|
|
24
|
+
android:id="@+id/B1"
|
|
25
|
+
android:layout_width="wrap_content"
|
|
26
|
+
android:layout_height="wrap_content"
|
|
27
|
+
android:layout_marginTop="40dp"
|
|
28
|
+
android:layout_marginEnd="144dp"
|
|
29
|
+
android:text="Implicit Intents"
|
|
30
|
+
app:layout_constraintTop_toBottomOf="@id/ExplicitButton"
|
|
31
|
+
app:layout_constraintEnd_toEndOf="parent" />
|
|
32
|
+
|
|
33
|
+
</android.support.constraint.ConstraintLayout>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<android.support.constraint.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=".SecondActivity">
|
|
9
|
+
|
|
10
|
+
<TextView
|
|
11
|
+
android:layout_width="wrap_content"
|
|
12
|
+
android:layout_height="wrap_content"
|
|
13
|
+
android:text="Welcome to Second Activity"
|
|
14
|
+
android:textSize="30sp"
|
|
15
|
+
app:layout_constraintTop_toTopOf="parent"
|
|
16
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
|
17
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
18
|
+
app:layout_constraintEnd_toEndOf="parent" />
|
|
19
|
+
|
|
20
|
+
</android.support.constraint.ConstraintLayout>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.example.explicitandimplicitintentsbypassingdata
|
|
2
|
+
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
import android.widget.Button
|
|
7
|
+
import android.widget.EditText
|
|
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 nameEt = findViewById<EditText>(R.id.nameEt)
|
|
16
|
+
val emailEt = findViewById<EditText>(R.id.emailEt)
|
|
17
|
+
val phoneEt = findViewById<EditText>(R.id.phoneEt)
|
|
18
|
+
val saveBtn = findViewById<Button>(R.id.saveBtn)
|
|
19
|
+
|
|
20
|
+
saveBtn.setOnClickListener {
|
|
21
|
+
|
|
22
|
+
// get data from edit texts
|
|
23
|
+
val name = nameEt.text.toString()
|
|
24
|
+
val email = emailEt.text.toString()
|
|
25
|
+
val phone = phoneEt.text.toString()
|
|
26
|
+
|
|
27
|
+
// intent to next activity
|
|
28
|
+
val intent = Intent(this, MainActivity2::class.java)
|
|
29
|
+
|
|
30
|
+
intent.putExtra("Name", name)
|
|
31
|
+
intent.putExtra("Email", email)
|
|
32
|
+
intent.putExtra("Phone", phone)
|
|
33
|
+
|
|
34
|
+
startActivity(intent)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.example.explicitandimplicitintentsbypassingdata
|
|
2
|
+
|
|
3
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.widget.TextView
|
|
6
|
+
|
|
7
|
+
class MainActivity2 : AppCompatActivity() {
|
|
8
|
+
|
|
9
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
10
|
+
super.onCreate(savedInstanceState)
|
|
11
|
+
setContentView(R.layout.activity_main2)
|
|
12
|
+
|
|
13
|
+
// get data from intent
|
|
14
|
+
val intent = intent
|
|
15
|
+
val name = intent.getStringExtra("Name")
|
|
16
|
+
val email = intent.getStringExtra("Email")
|
|
17
|
+
val phone = intent.getStringExtra("Phone")
|
|
18
|
+
|
|
19
|
+
// display data
|
|
20
|
+
val resultTv = findViewById<TextView>(R.id.resultTv)
|
|
21
|
+
resultTv.text = "Name: $name\nEmail: $email\nPhone: $phone"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<LinearLayout
|
|
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
|
+
android:orientation="vertical"
|
|
9
|
+
tools:context=".MainActivity">
|
|
10
|
+
|
|
11
|
+
<EditText
|
|
12
|
+
android:id="@+id/nameEt"
|
|
13
|
+
android:layout_width="match_parent"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:hint="Enter Name"
|
|
16
|
+
android:inputType="text" />
|
|
17
|
+
|
|
18
|
+
<EditText
|
|
19
|
+
android:id="@+id/emailEt"
|
|
20
|
+
android:layout_width="match_parent"
|
|
21
|
+
android:layout_height="wrap_content"
|
|
22
|
+
android:hint="Enter Email"
|
|
23
|
+
android:inputType="textEmailAddress" />
|
|
24
|
+
|
|
25
|
+
<EditText
|
|
26
|
+
android:id="@+id/phoneEt"
|
|
27
|
+
android:layout_width="match_parent"
|
|
28
|
+
android:layout_height="wrap_content"
|
|
29
|
+
android:hint="Enter Phone"
|
|
30
|
+
android:inputType="phone" />
|
|
31
|
+
|
|
32
|
+
<Button
|
|
33
|
+
android:id="@+id/saveBtn"
|
|
34
|
+
android:layout_width="wrap_content"
|
|
35
|
+
android:layout_height="wrap_content"
|
|
36
|
+
android:text="save" />
|
|
37
|
+
|
|
38
|
+
</LinearLayout>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<LinearLayout
|
|
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=".MainActivity2">
|
|
9
|
+
|
|
10
|
+
<TextView
|
|
11
|
+
android:id="@+id/resultTv"
|
|
12
|
+
android:layout_width="match_parent"
|
|
13
|
+
android:layout_height="wrap_content"
|
|
14
|
+
android:textSize="30sp"
|
|
15
|
+
android:textStyle="bold"
|
|
16
|
+
android:textColor="#000" />
|
|
17
|
+
|
|
18
|
+
</LinearLayout>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.example.imageview
|
|
2
|
+
|
|
3
|
+
import android.os.Bundle
|
|
4
|
+
import android.support.v7.app.AppCompatActivity
|
|
5
|
+
import android.view.View
|
|
6
|
+
import android.widget.Toast
|
|
7
|
+
|
|
8
|
+
class MainActivity : AppCompatActivity() {
|
|
9
|
+
|
|
10
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
11
|
+
super.onCreate(savedInstanceState)
|
|
12
|
+
setContentView(R.layout.activity_main)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
fun donut(view: View) {
|
|
16
|
+
Toast.makeText(
|
|
17
|
+
this,
|
|
18
|
+
"Donut clicked!",
|
|
19
|
+
Toast.LENGTH_SHORT
|
|
20
|
+
).show()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fun choco(view: View) {
|
|
24
|
+
Toast.makeText(
|
|
25
|
+
this,
|
|
26
|
+
"Chocolate clicked!",
|
|
27
|
+
Toast.LENGTH_SHORT
|
|
28
|
+
).show()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
fun ice(view: View) {
|
|
32
|
+
Toast.makeText(
|
|
33
|
+
this,
|
|
34
|
+
"IceCream clicked!",
|
|
35
|
+
Toast.LENGTH_SHORT
|
|
36
|
+
).show()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
|
|
3
|
+
<LinearLayout
|
|
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:orientation="vertical"
|
|
10
|
+
tools:context=".MainActivity">
|
|
11
|
+
|
|
12
|
+
<LinearLayout
|
|
13
|
+
android:layout_width="wrap_content"
|
|
14
|
+
android:layout_height="wrap_content"
|
|
15
|
+
android:orientation="horizontal">
|
|
16
|
+
|
|
17
|
+
<ImageView
|
|
18
|
+
android:id="@+id/imageView"
|
|
19
|
+
android:layout_width="200dp"
|
|
20
|
+
android:layout_height="200dp"
|
|
21
|
+
android:layout_weight="1"
|
|
22
|
+
android:onClick="donut"
|
|
23
|
+
android:paddingBottom="10dp"
|
|
24
|
+
android:src="@drawable/donut" />
|
|
25
|
+
|
|
26
|
+
<TextView
|
|
27
|
+
android:id="@+id/donuttext"
|
|
28
|
+
android:layout_width="wrap_content"
|
|
29
|
+
android:layout_height="wrap_content"
|
|
30
|
+
android:layout_weight="1"
|
|
31
|
+
android:text="HELLO I AM A DONUT .EAT ME YOYO"
|
|
32
|
+
android:paddingTop="70dp"
|
|
33
|
+
android:paddingLeft="20dp"
|
|
34
|
+
android:textSize="18sp" />
|
|
35
|
+
|
|
36
|
+
</LinearLayout>
|
|
37
|
+
|
|
38
|
+
<LinearLayout
|
|
39
|
+
android:layout_width="match_parent"
|
|
40
|
+
android:layout_height="287dp"
|
|
41
|
+
android:orientation="horizontal">
|
|
42
|
+
|
|
43
|
+
<ImageView
|
|
44
|
+
android:id="@+id/imageView2"
|
|
45
|
+
android:layout_width="200dp"
|
|
46
|
+
android:layout_height="200dp"
|
|
47
|
+
android:layout_weight="1"
|
|
48
|
+
android:onClick="choco"
|
|
49
|
+
android:paddingBottom="10dp"
|
|
50
|
+
app:srcCompat="@drawable/choco" />
|
|
51
|
+
|
|
52
|
+
<TextView
|
|
53
|
+
android:id="@+id/textView3"
|
|
54
|
+
android:layout_width="wrap_content"
|
|
55
|
+
android:layout_height="wrap_content"
|
|
56
|
+
android:layout_weight="1"
|
|
57
|
+
android:paddingTop="70dp"
|
|
58
|
+
android:text="haha...u cant eat me"
|
|
59
|
+
android:textSize="18sp" />
|
|
60
|
+
|
|
61
|
+
</LinearLayout>
|
|
62
|
+
|
|
63
|
+
<LinearLayout
|
|
64
|
+
android:layout_width="wrap_content"
|
|
65
|
+
android:layout_height="wrap_content"
|
|
66
|
+
android:orientation="horizontal">
|
|
67
|
+
|
|
68
|
+
<ImageView
|
|
69
|
+
android:id="@+id/imageView4"
|
|
70
|
+
android:layout_width="200dp"
|
|
71
|
+
android:layout_height="200dp"
|
|
72
|
+
android:layout_weight="1"
|
|
73
|
+
android:onClick="ice"
|
|
74
|
+
android:paddingBottom="10dp"
|
|
75
|
+
android:src="@drawable/finalme" />
|
|
76
|
+
|
|
77
|
+
<TextView
|
|
78
|
+
android:id="@+id/icetext"
|
|
79
|
+
android:layout_width="wrap_content"
|
|
80
|
+
android:layout_height="wrap_content"
|
|
81
|
+
android:layout_weight="1"
|
|
82
|
+
android:text="ICE CREAM ---------------"
|
|
83
|
+
android:paddingTop="70dp"
|
|
84
|
+
android:paddingLeft="20dp"
|
|
85
|
+
android:textSize="18sp" />
|
|
86
|
+
|
|
87
|
+
</LinearLayout>
|
|
88
|
+
|
|
89
|
+
</LinearLayout>
|