Outline ·
[ Standard ] ·
Linear+
Java can i override with additional parameter ?
TSnarf03
|
Nov 20 2018, 12:59 AM, updated 6y ago
|
|
its going to be kotlin, there isnt a kotlin tag so im going to assume they are equivalent and im not using the code tag for the majority of the code cause some info will be missing refer to the code below, i able to call the window using CODE MessageBox().show(supportFragmentManager, "") now my question is, how do i pass in additional parameters(ie title and description text that shows up on the messagebox) from the above code into the "MessageBox : DialogFragment()" ? i dont want to hardcode the Messagebox class, i assume ill be having plenty of them, and those buttons on the messagebox will not do anything beside just closing the messagebox. and if possible, 1 line of code only.
|
|
|
|
TSnarf03
|
Nov 20 2018, 07:35 AM
|
|
nvm, i solve it by not overriding =P CODE class MessageBox : DialogFragment(){ var strMessage = "" var strTitle = "" override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return activity?.let { this.isCancelable = false val builder = AlertDialog.Builder(it) builder.setTitle(strTitle) builder.setMessage(strMessage) builder.setPositiveButton("OK") { dialog, id -> } builder.setNegativeButton("Cancel") { dialog, id -> } builder.create() } ?: throw IllegalStateException("Activity cannot be null") }
fun show(fm: FragmentManager, strTitle : String, strMessage : String) { this.strTitle = strTitle this.strMessage = strMessage this.show(fm, "")
} }
|
|
|
|