Last active
February 18, 2019 15:38
-
-
Save lynas/dcba002ce5afabf6454c8765ab3f3430 to your computer and use it in GitHub Desktop.
android fragment using anko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyFragment: Fragment(){ | |
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
return UI { | |
linearLayout{ | |
editText() | |
button("OK") | |
} | |
}.view | |
} | |
} | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val fragment = MyFragment() | |
linearLayout { | |
id = 1 | |
fragmentManager.beginTransaction().replace(1,fragment).commit() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment