Skip to content

Commit 6455a85

Browse files
committed
Spinner example Included
1 parent 0198903 commit 6455a85

File tree

6 files changed

+62
-1
lines changed

6 files changed

+62
-1
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
android:roundIcon="@mipmap/ic_launcher_round"
1313
android:supportsRtl="true"
1414
android:theme="@style/AppTheme">
15+
<activity android:name=".Widgets.Spinner.SpinnerActivity">
16+
</activity>
1517
<activity android:name=".Widgets.RatingBar.RatingBar">
1618
</activity>
1719
<activity android:name=".Widgets.CheckBox.CheckBox">
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package source.open.akash.kotlinexample.Widgets.Spinner
2+
3+
import android.os.Bundle
4+
import android.widget.ArrayAdapter
5+
import androidx.appcompat.app.AppCompatActivity
6+
import kotlinx.android.synthetic.main.activity_spinner.*
7+
import source.open.akash.kotlinexample.R
8+
9+
class SpinnerActivity : AppCompatActivity() {
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
setContentView(R.layout.activity_spinner)
14+
val listDropdown = mutableListOf<String>("Select", "Modi Ji", "Manmohan Singh Ji ", "Ram Nath Kovind Ji ")
15+
val arrayAdapter = ArrayAdapter(this@SpinnerActivity, android.R.layout.simple_spinner_item, listDropdown)
16+
spinner.adapter = arrayAdapter
17+
18+
}
19+
}

app/src/main/java/source/open/akash/kotlinexample/Widgets/Widgets.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import source.open.akash.kotlinexample.Widgets.CheckBox.CheckBox
1010
import source.open.akash.kotlinexample.Widgets.EditText.EditText
1111
import source.open.akash.kotlinexample.Widgets.RadioButton.RadioButton
1212
import source.open.akash.kotlinexample.Widgets.RatingBar.RatingBar
13+
import source.open.akash.kotlinexample.Widgets.Spinner.SpinnerActivity
1314
import source.open.akash.kotlinexample.Widgets.TextView.TextView
1415

1516
class Widgets : AppCompatActivity() {
@@ -43,5 +44,9 @@ class Widgets : AppCompatActivity() {
4344
val intent = Intent(this, RatingBar::class.java)
4445
startActivity(intent)
4546
}
47+
SpinnerDemo.setOnClickListener {
48+
val intent = Intent(this, SpinnerActivity::class.java)
49+
startActivity(intent)
50+
}
4651
}
4752
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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:tools="http://schemas.android.com/tools"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context=".Widgets.Spinner.SpinnerActivity">
9+
<TextView android:layout_width="match_parent"
10+
app:layout_constraintLeft_toLeftOf="parent"
11+
app:layout_constraintBottom_toBottomOf="parent"
12+
app:layout_constraintRight_toRightOf="parent"
13+
android:text="Our Prime Minister Name is : "
14+
app:layout_constraintBottom_toTopOf="@+id/spinner"
15+
app:layout_constraintTop_toTopOf="parent"
16+
android:layout_height="wrap_content"/>
17+
18+
<Spinner
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
app:layout_constraintLeft_toLeftOf="parent"
22+
app:layout_constraintBottom_toBottomOf="parent"
23+
app:layout_constraintRight_toRightOf="parent"
24+
app:layout_constraintTop_toTopOf="parent"
25+
android:id="@+id/spinner"/>
26+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/layout/activity_widgets.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,14 @@
6060
android:background="@drawable/rectshape"
6161
android:layout_width="match_parent"
6262
android:layout_height="wrap_content"/>
63+
<TextView
64+
android:layout_marginTop="10dp"
65+
android:id="@+id/SpinnerDemo"
66+
android:gravity="center"
67+
android:text="7. Spinner"
68+
android:padding="10dp"
69+
android:background="@drawable/rectshape"
70+
android:layout_width="match_parent"
71+
android:layout_height="wrap_content"/>
6372

6473
</LinearLayout>

0 commit comments

Comments
 (0)