Created
January 19, 2016 23:37
-
-
Save grim13b/b4536b7d2dda507e8118 to your computer and use it in GitHub Desktop.
Fragment に Kotlin + Anko を使った Example
This file contains hidden or 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 org.grim3lt.android.kotlinexample22 | |
import android.os.AsyncTask | |
import android.support.v4.app.Fragment | |
import android.os.Bundle | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import org.jetbrains.anko.* | |
import org.jetbrains.anko.support.v4.UI | |
class MainActivityFragment : Fragment() { | |
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, | |
savedInstanceState: Bundle?): View? { | |
return UI { | |
relativeLayout { | |
verticalLayout { | |
button("お越しの方はこちらのボタンでお呼びください。") { | |
textSize = 24f | |
onClick { | |
object : AsyncTask<Unit, Unit, String>() { | |
override protected fun doInBackground(vararg params: Unit?): String? { | |
Thread.sleep(5000) | |
return "Success" | |
} | |
override fun onPreExecute() { | |
super.onPreExecute() | |
isClickable = false | |
isEnabled = false | |
toast("ぴんぽーーーーーーん") | |
} | |
override fun onPostExecute(result: String?) { | |
super.onPostExecute(result) | |
isClickable = true | |
isEnabled = true | |
toast("ぴんぽーーーーーーん解除") | |
} | |
}.execute() | |
} | |
} | |
} | |
} | |
}.view | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment