Skip to content

Commit fbb1861

Browse files
author
Nicolas Sauter
committed
In Kotlin
1 parent d2f4c4f commit fbb1861

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

AlertDialog mit Prompt für Eingaben.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,44 @@ public void onClick(DialogInterface dialog, int id) {
5555

5656
}
5757

58-
}
58+
}
59+
60+
// In Kotlin &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
61+
package android.example.myapplication
62+
63+
import android.os.Bundle
64+
import android.text.InputType
65+
import android.util.Log
66+
import android.widget.EditText
67+
import androidx.appcompat.app.AlertDialog
68+
import androidx.appcompat.app.AppCompatActivity
69+
70+
71+
class MainActivity : AppCompatActivity() {
72+
override fun onCreate(savedInstanceState: Bundle?) {
73+
super.onCreate(savedInstanceState)
74+
setContentView(R.layout.activity_main)
75+
76+
77+
78+
val aDB = AlertDialog.Builder(this)
79+
.setTitle("Der Titel")
80+
.setMessage("Bla bla bla")
81+
82+
83+
//**** EditText is a prompt field! *****************
84+
val eT = EditText(this)
85+
eT.inputType = InputType.TYPE_CLASS_TEXT
86+
aDB.setView(eT)
87+
//**** End EditText prompt field *******************
88+
89+
90+
// set dialog message
91+
aDB
92+
.setCancelable(false)
93+
.setPositiveButton("OK") { dialog, id -> Log.d("TAG", "Result: ${eT.text}") }
94+
.setNegativeButton("Cancel") { dialog, id -> dialog.cancel() }
95+
.create().show()
96+
}
97+
}
98+
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

0 commit comments

Comments
 (0)