Skip to content

Commit e3f5906

Browse files
committed
Chapter 2
1 parent f207843 commit e3f5906

File tree

14 files changed

+206
-9
lines changed

14 files changed

+206
-9
lines changed

ArtBookApp/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ArtBookApp/.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ArtBookApp/.idea/gradle.xml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ArtBookApp/.idea/jarRepositories.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ArtBookApp/.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ArtBookApp/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ArtBookApp/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id 'com.android.application'
33
id 'kotlin-android'
4+
id 'kotlin-android-extensions'
5+
46
}
57

68
android {

ArtBookApp/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
1111
android:theme="@style/Theme.ArtBookApp">
12+
<activity android:name=".MainActivity2"></activity>
1213
<activity android:name=".MainActivity">
1314
<intent-filter>
1415
<action android:name="android.intent.action.MAIN" />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
package com.merttan.artbookapp
22

3+
import android.content.Intent
34
import androidx.appcompat.app.AppCompatActivity
45
import android.os.Bundle
6+
import android.view.Menu
7+
import android.view.MenuItem
58

69
class MainActivity : AppCompatActivity() {
710
override fun onCreate(savedInstanceState: Bundle?) {
811
super.onCreate(savedInstanceState)
912
setContentView(R.layout.activity_main)
1013
}
14+
15+
// biraz once oluşturduğum menüyü buraya bağlıyoruz
16+
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
17+
val menuInflater=menuInflater
18+
menuInflater.inflate(R.menu.add_art,menu)
19+
return super.onCreateOptionsMenu(menu)
20+
21+
}
22+
23+
// seçilen itemin ne olduğunu anlayıp ona göre iş yapturuyoruz
24+
override fun onOptionsItemSelected(item: MenuItem): Boolean {
25+
if(item.itemId== R.id.add_art_item){
26+
val intent= Intent(this, MainActivity2::class.java)
27+
startActivity(intent)
28+
29+
}
30+
return super.onOptionsItemSelected(item)
31+
}
32+
33+
34+
1135
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.merttan.artbookapp
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import android.view.View
6+
7+
class MainActivity2 : AppCompatActivity() {
8+
override fun onCreate(savedInstanceState: Bundle?) {
9+
super.onCreate(savedInstanceState)
10+
setContentView(R.layout.activity_main2)
11+
}
12+
13+
14+
fun selectImage(view : View){
15+
16+
}
17+
}
Loading

ArtBookApp/app/src/main/res/layout/activity_main.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
77
tools:context=".MainActivity">
8-
9-
<TextView
10-
android:layout_width="wrap_content"
11-
android:layout_height="wrap_content"
12-
android:text="Hello World!"
8+
<ListView
9+
android:id="@+id/listView"
10+
android:layout_width="0dp"
11+
android:layout_height="0dp"
12+
android:layout_marginStart="1dp"
13+
android:layout_marginTop="1dp"
14+
android:layout_marginEnd="1dp"
15+
android:layout_marginBottom="1dp"
1316
app:layout_constraintBottom_toBottomOf="parent"
14-
app:layout_constraintLeft_toLeftOf="parent"
15-
app:layout_constraintRight_toRightOf="parent"
17+
app:layout_constraintEnd_toEndOf="parent"
18+
app:layout_constraintStart_toStartOf="parent"
1619
app:layout_constraintTop_toTopOf="parent" />
17-
18-
</androidx.constraintlayout.widget.ConstraintLayout>
20+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".MainActivity2">
8+
9+
<ImageView
10+
android:id="@+id/imageView"
11+
android:layout_width="0dp"
12+
android:layout_height="0dp"
13+
android:layout_marginStart="37dp"
14+
android:layout_marginTop="16dp"
15+
android:layout_marginEnd="37dp"
16+
android:layout_marginBottom="227dp"
17+
android:onClick="selectImage"
18+
app:layout_constraintBottom_toTopOf="@+id/button"
19+
app:layout_constraintEnd_toEndOf="parent"
20+
app:layout_constraintStart_toStartOf="parent"
21+
app:layout_constraintTop_toTopOf="parent"
22+
app:srcCompat="@drawable/selectimage" />
23+
24+
<EditText
25+
android:id="@+id/artText"
26+
android:layout_width="wrap_content"
27+
android:layout_height="wrap_content"
28+
android:layout_marginBottom="22dp"
29+
android:ems="10"
30+
android:hint="Art Name"
31+
android:inputType="textPersonName"
32+
app:layout_constraintBottom_toTopOf="@+id/artistText"
33+
app:layout_constraintEnd_toEndOf="parent"
34+
app:layout_constraintStart_toStartOf="parent"
35+
app:layout_constraintTop_toBottomOf="@+id/imageView" />
36+
37+
<EditText
38+
android:id="@+id/yearText"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:layout_marginBottom="185dp"
42+
android:ems="10"
43+
android:hint="Year"
44+
android:inputType="textPersonName"
45+
app:layout_constraintBottom_toBottomOf="parent"
46+
app:layout_constraintStart_toStartOf="@+id/artistText"
47+
app:layout_constraintTop_toBottomOf="@+id/artistText" />
48+
49+
<EditText
50+
android:id="@+id/artistText"
51+
android:layout_width="wrap_content"
52+
android:layout_height="wrap_content"
53+
android:layout_marginBottom="19dp"
54+
android:ems="10"
55+
android:hint="Artist Name"
56+
android:inputType="textPersonName"
57+
app:layout_constraintBottom_toTopOf="@+id/yearText"
58+
app:layout_constraintStart_toStartOf="@+id/artText"
59+
app:layout_constraintTop_toBottomOf="@+id/artText" />
60+
61+
<Button
62+
android:id="@+id/button"
63+
android:layout_width="wrap_content"
64+
android:layout_height="wrap_content"
65+
android:layout_marginBottom="102dp"
66+
android:onClick="save"
67+
android:text="Save"
68+
app:layout_constraintBottom_toBottomOf="parent"
69+
app:layout_constraintEnd_toEndOf="parent"
70+
app:layout_constraintStart_toStartOf="parent"
71+
app:layout_constraintTop_toBottomOf="@+id/imageView" />
72+
73+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item
4+
android:id="@+id/add_art_item"
5+
android:title="Add art">
6+
7+
</item>
8+
</menu>

0 commit comments

Comments
 (0)