File tree Expand file tree Collapse file tree 5 files changed +57
-10
lines changed
MyFirstKotlinApp/app/src/main
java/br/com/haysarodrigues/myfirstkotlinapp Expand file tree Collapse file tree 5 files changed +57
-10
lines changed Original file line number Diff line number Diff line change 1616 <category android : name =" android.intent.category.LAUNCHER" />
1717 </intent-filter >
1818 </activity >
19+ <activity android : name =" .IntentActivity" />
1920 </application >
2021
2122</manifest >
Original file line number Diff line number Diff line change 1+ package br.com.haysarodrigues.myfirstkotlinapp
2+
3+ import android.os.Bundle
4+ import android.os.PersistableBundle
5+ import android.support.v7.app.AppCompatActivity
6+
7+ /* *
8+ * Created by Haysa on 20/01/18.
9+ */
10+ class IntentActivity : AppCompatActivity (){
11+
12+ override fun onCreate (savedInstanceState : Bundle ? , persistentState : PersistableBundle ? ) {
13+ super .onCreate(savedInstanceState, persistentState)
14+ setContentView(R .layout.activity_intent)
15+
16+ }
17+
18+ }
Original file line number Diff line number Diff line change 11package br.com.haysarodrigues.myfirstkotlinapp
22
3+ import android.content.Context
4+ import android.content.Intent
35import android.support.v7.app.AppCompatActivity
46import android.os.Bundle
57import kotlinx.android.synthetic.main.activity_main.*
8+ import org.jetbrains.anko.AnkoAsyncContext
69import org.jetbrains.anko.toast
710
811class MainActivity : AppCompatActivity () {
@@ -26,5 +29,13 @@ class MainActivity : AppCompatActivity() {
2629 toast(" Y is: ${x} " )
2730
2831 }
32+
33+ /* * This is a way to call an activity using Intent */
34+ intentButton.setOnClickListener{
35+ val intent = Intent (this , IntentActivity ::class .java)
36+ startActivity(intent)
37+ }
2938 }
3039}
40+
41+
Original file line number Diff line number Diff line change 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 : tools =" http://schemas.android.com/tools"
5+ android : layout_width =" match_parent"
6+ android : layout_height =" match_parent" >
7+
8+ <TextView
9+ android : id =" @+id/welcomeMessage"
10+ android : layout_width =" wrap_content"
11+ android : layout_height =" wrap_content"
12+ android : layout_gravity =" center"
13+ android : text =" Hello World!" />
14+
15+ </android .support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change 66 android : layout_height =" match_parent"
77 tools : context =" br.com.haysarodrigues.myfirstkotlinapp.MainActivity" >
88
9- <TextView
10- android : id =" @+id/textView"
11- android : layout_width =" wrap_content"
12- android : layout_height =" wrap_content"
13- android : text =" Hello World!"
14- app : layout_constraintBottom_toBottomOf =" parent"
15- app : layout_constraintLeft_toLeftOf =" parent"
16- app : layout_constraintRight_toRightOf =" parent"
17- app : layout_constraintTop_toTopOf =" parent" />
18-
199 <EditText
2010 android : id =" @+id/userName"
2111 android : layout_width =" match_parent"
4030 app : layout_constraintStart_toStartOf =" @+id/userName"
4131 app : layout_constraintTop_toBottomOf =" @+id/userName" />
4232
33+ <Button
34+ android : id =" @+id/intentButton"
35+ android : layout_width =" 0dp"
36+ android : layout_height =" wrap_content"
37+ android : layout_marginEnd =" 8dp"
38+ android : layout_marginStart =" 8dp"
39+ android : layout_marginTop =" 8dp"
40+ android : text =" Intent"
41+ app : layout_constraintEnd_toEndOf =" parent"
42+ app : layout_constraintStart_toStartOf =" parent"
43+ app : layout_constraintTop_toBottomOf =" @+id/button1" />
44+
4345</android .support.constraint.ConstraintLayout>
You can’t perform that action at this time.
0 commit comments