I have some Android app, which is mixture of Java and Kotlin and inside this app I have Listview , which contains available WiFi
networks. When I select element of this ListView
, Dialog pops up asking for user intervention, which is all ok so far. Now, when I press Submit button , this Dialog
hides and the selected ListView
's item's ImageView should get Steelblue color, but it does not:
dialog.buttonNewGroup.setOnClickListener { _: View? ->
val newGroupDialog: MaterialDialog = MaterialDialog.Builder(this@AddDevicesActivity)
.title(R.string.new_group_dialog_title)
.content(R.string.new_group_dialog_content)
.inputType(InputType.TYPE_CLASS_TEXT
+ InputType.TYPE_TEXT_VARIATION_NORMAL
+ InputType.TYPE_TEXT_FLAG_AUTO_CORRECT + InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE + InputType.TYPE_TEXT_FLAG_CAP_SENTENCES)
.inputRange(1, 32)
.input(R.string.group_name, 0, false, { _, _ -> })
.negativeText(R.string.cancel)
.positiveText(R.string.submit)
.onPositive { dialog, _ ->
// Add new group to database
mDb.addGroup(VentGroup(dialog.inputEditText?.text.toString()))
// Get refreshed list of the groups
mGroups.clear()
mDb.getGroups().toCollection(mGroups)
mGroupsAdapter.notifyDataSetChanged()
this@AddDevicesActivity.imageView.setBackgroundColor(Color.parseColor("0xff4682b4")) // IMAGE BACKGROUND DOES NOT CHANGE TO "Steelblue" color
}
.build()
newGroupDialog.show()
}
I've added breakpoint in this part of code and it DOES GETS executed, however, the background
of ImageView
does not change. Why?
PS: I am new to Kotlin
and rather new in Android/Java
and I ask for a little understanding before downvoting, since I am aware there must be some dumb mistake behind it.
您好KernelPanic试试,
(dialog.actiivty as AddDevicesActivity).imageView.setBackgroundColor(Color.parseColor("0xff4682br"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.