Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 1.34 KB

EditText_Event.md

File metadata and controls

60 lines (43 loc) · 1.34 KB

1. setOnClickListener

content.setOnClickListener(View.OnClickListener {
  //content.selectionStart
  //content.selectionEnd
  //content.setSelection(position)
})

2. addTextChangedListener

content.addTextChangedListener(object: TextWatcher {
    override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {

    }

    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
    
    }

    override fun afterTextChanged(s: Editable?) {

    }
})

3. removeTextChangedListener

content.removeTextChangedListener(object: TextWatcher {
    override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
        
    }

    override fun afterTextChanged(s: Editable?) {
        
    }

    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
        
    }
})

4. setAccessibilityDelegate

 content.setAccessibilityDelegate(object : View.AccessibilityDelegate() {
    override fun sendAccessibilityEvent(host: View?, eventType: Int) {
        super.sendAccessibilityEvent(host, eventType)
        if (eventType == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED){
              //content.selectionStart
              //content.selectionEnd
              //content.setSelection(position)
        }
    }
})