Skip to content

Commit f752533

Browse files
committed
Completed project
1 parent 53243d1 commit f752533

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

app/src/main/java/com/mindorks/editdrawabletextsample/MainActivity.kt

+14-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,27 @@ class MainActivity : AppCompatActivity() {
1313
super.onCreate(savedInstanceState)
1414
setContentView(R.layout.activity_main)
1515
val drawable_editText: EditDrawableText = findViewById(R.id.drawable_editText)
16-
onClickListeners(drawable_editText)
16+
val drawable_editText_left: EditDrawableText = findViewById(R.id.drawable_editText_left)
17+
onClickListeners(
18+
drawable_editText,
19+
drawable_editText_left
20+
)
1721

1822
}
1923

20-
private fun onClickListeners(drawable_editText: EditDrawableText) {
24+
private fun onClickListeners(drawable_editText: EditDrawableText, drawable_editText_left: EditDrawableText) {
2125
drawable_editText.setDrawableClickListener(object : onDrawableClickListener {
2226
override fun onClick(target: DrawablePosition) {
2327
when (target) {
2428
DrawablePosition.RIGHT -> displayToastMessage("Clicked Right Drawable").show()
29+
}
30+
}
31+
32+
33+
})
34+
drawable_editText_left.setDrawableClickListener(object : onDrawableClickListener {
35+
override fun onClick(target: DrawablePosition) {
36+
when (target) {
2537
DrawablePosition.LEFT -> displayToastMessage("Clicked Left Drawable").show()
2638
}
2739
}

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:orientation="vertical"
78
android:padding="20dp"
89
tools:context=".MainActivity">
910

@@ -12,6 +13,18 @@
1213
android:layout_width="match_parent"
1314
android:layout_height="wrap_content"
1415
android:drawableRight="@drawable/ic_remove_red_eye_black_24dp"
16+
android:hint="@string/clickTheDrawables"
17+
android:inputType="text"
18+
android:textAlignment="center"
19+
app:layout_constraintBottom_toBottomOf="parent"
20+
app:layout_constraintLeft_toLeftOf="parent"
21+
app:layout_constraintRight_toRightOf="parent"
22+
app:layout_constraintTop_toTopOf="parent" />
23+
<com.mindorks.editdrawabletext.EditDrawableText
24+
android:id="@+id/drawable_editText_left"
25+
android:layout_width="match_parent"
26+
android:layout_marginTop="10dp"
27+
android:layout_height="wrap_content"
1528
android:drawableLeft="@drawable/ic_remove_red_eye_black_24dp"
1629
android:hint="@string/clickTheDrawables"
1730
android:inputType="text"
@@ -21,4 +34,4 @@
2134
app:layout_constraintRight_toRightOf="parent"
2235
app:layout_constraintTop_toTopOf="parent" />
2336

24-
</RelativeLayout>
37+
</LinearLayout>

0 commit comments

Comments
 (0)