LoginSignup
1

More than 5 years have passed since last update.

Kotlinでアプリを動かすお勉強3

Last updated at Posted at 2018-11-17

文字列はリソースとしてxmlで定義しておけるみたい

[Android & Kotlin] EditText の文字を入力する
https://akira-watson.com/android/kotlin/edit-text.html

ビルドについて

アプリをビルドして実行する  |  Android Developers
https://developer.android.com/studio/run/?utm_source=android-studio

フラグメントをつかってスワイプしてページするUIの参考例

androidアプリ開発 kotlin部 : kotlinでTabLayoutとViewPagerで横スワイプしてタブを切り替える方法
http://android.techblog.jp/archives/9965810.html

イベントをフラグメントで実装する参考例

[Kotlin] ViewPagerとFragmentPagerAdapterでスワイプによるページの切り替え - JoyPlotドキュメント
https://joyplot.com/documents/2018/01/10/kotlin-viewpager-swipe/

【Android学習】FragmentをKotlinでやってみる - My Note Pad
http://yuki10.hatenablog.com/entry/2018/04/29/222447

view.findViewById<Button>(R.id.numberButton).setOnClickListener {
    mTextView.text = "${mTextView.text}!"
}

フラグメントマネージャーは抽象に沿う

KotlinでListViewを内包したTabを作成する | すいすいSwift
https://swiswiswift.com/2018/09/25/list-in-tab/

getPageTitleというのを使うとビュー側でなくてアダプター側でタイトルを管理できた
getterはメソッドじゃなくてプロパティで参照するのね

findFragmentByPositionつかった

ViewPagerで現在のページのFragmentを取得する方法 - Qiita
https://qiita.com/chooblarin/items/88b4accac0cbb6944d4b

最後.特に問題にならないのであればこの方法を使うのが良いと思います.[3]

演算子で手間取った

ちょくちょく見そう

30分で覚えるKotlin文法 - Qiita
https://qiita.com/k5n/items/cc0377b75d8537ef8a85

Kotlin文法 - this、等価性、演算子オーバーロード、Null安全、例外 - Qiita
https://qiita.com/k5n/items/6fe586bf2e5530684681#%E3%82%A8%E3%83%AB%E3%83%93%E3%82%B9%E6%BC%94%E7%AE%97%E5%AD%90

Kotlinの基本型 - 算譜王におれはなる!!!!
https://taro.hatenablog.jp/entry/20120111/1326297175

論理演算子は関数で。
if (inputTel.text.toString().length != (10 or 11)) {
    ...hoge
}

// === 演算子は参照先が同じかどうかをチェックする

Flow-Sensitive Type

まだよく理解してない。。
型推論に癖(?)があるくらいの認識。

あなたの知らないKotlinのsmart cast - Qiita
https://qiita.com/kmizu/items/2831cde52c055367535c

安全なキャストができます、というのは不正確で、KotlinはFlow-Sensitive Typeと呼ばれる型システムを持っています。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1