open class Parent {
constructor(name: String) {
// 构造函数实现
}
constructor(name: String, age: Int) {
// 构造函数实现
}
}
class Child : Parent {
constructor(name: String) : super(name) {
// 子类构造函数实现
}
constructor(name: String, age: Int) : super(name, age) {
// 子类构造函数实现
}
}
class MediaGridSpacingItemDecoration1 : RecyclerView.ItemDecoration {
private val DIRECTION_HORIZONTAL = 0
private val DIRECTION_VERTICAL = 1
private var mDirection // horizontal or vertical
= 0
private var mSpanCount = 0
private var mOffset = 0
private val mSpacing = 0
private var mHspacing = 0
private var mVspacing = 0
private var mIncludeEdge = false
public constructor(
direction: Int, spanCount: Int, offset: Int, hspacing: Int,
vspacing: Int, includeEdge: Boolean) : super(){
mDirection = direction
mSpanCount = spanCount
mOffset = offset
mHspacing = hspacing
mVspacing = vspacing
mIncludeEdge = includeEdge
}
public constructor(
direction: Int) : this(direction, 0, 0, 0 ,0 ,false)
}
class SettingEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
AppCompatEditText(context, attrs, defStyleAttr) {
init {
init()
}
fun init() {
customSelectionActionModeCallback = object : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
val size = menu.size()
for (i in 0 until size) {
val item = menu.getItem(i)
val itemId = item.itemId
if (itemId != R.id.cut && itemId != R.id.copy && itemId != R.id.selectAll && itemId != R.id.paste) {
item.isVisible = false
}
}
return true
}
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
return false
}
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
return false
}
override fun onDestroyActionMode(mode: ActionMode) {}
}
}
}