A simple ViewGroup extends FrameLayout and draws multiple EditText's over TextView.
Sample app is quiz-like text string with 4 empty spots.
- Setup where to draw EditText's like integer pairs (startOffset, endOffset)
ArrayList<QuizSpot>().apply {
add(QuizSpot(0, 6))
add(QuizSpot(10, 14))
add(QuizSpot(22, 33))
add(QuizSpot(93, 98))
}
- Setup onFocusChangeListener for EditText's. You can, for example, show hint for each spot when it is active.
quizView.spotFocusChangeListener = View.OnFocusChangeListener { v, hasFocus ->
// show hint or log or whatever
}
- Supports accesibility in navigation: you can use
next
keyboard action orTab
on hardware keyboard. You can setupcheck
View (here you may want to check if answer are correct) and it will become active duringtab
navigation after last EditText andnext
action will return focus to first EditText.
quizView.viewCheck = btnAnswers