Skip to content

Instantly share code, notes, and snippets.

@kingori
Created January 29, 2019 07:09
Show Gist options
  • Save kingori/518e8afcb6fb4d90b81eb8348395f39e to your computer and use it in GitHub Desktop.
Save kingori/518e8afcb6fb4d90b81eb8348395f39e to your computer and use it in GitHub Desktop.
package com.example.myapplication
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import java.io.Serializable
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
btn_move.setOnClickListener {
startActivity(Intent(this, MainActivity::class.java).putExtra("user", User()))
}
}
override fun onSaveInstanceState(outState: Bundle?) {
super.onSaveInstanceState(outState)
outState?.putSerializable("user", User())
}
}
class User: Serializable {
val _name = Name("wilson", Name.NameType.A)
val nameType by lazy {
_name.nameType
}
}
class Name(val text:String, val nameType:NameType): Serializable {
enum class NameType {
A,B
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment