Created
January 29, 2019 07:09
-
-
Save kingori/518e8afcb6fb4d90b81eb8348395f39e to your computer and use it in GitHub Desktop.
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
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