Kotlin for Android Developers


Download 1.04 Mb.
Pdf ko'rish
bet67/79
Sana18.06.2023
Hajmi1.04 Mb.
#1588404
1   ...   63   64   65   66   67   68   69   70   ...   79
Bog'liq
Kotlin for Android Developers Learn Kotlin the Easy Way While Developing an Android App ( PDFDrive )

initToolbar()
5
6
forecastList.layoutManager = LinearLayoutManager(this)
7
attachToScroll(forecastList)
8
9
async {
10
val result = RequestForecastCommand(94043).execute()
11
uiThread {
12
val adapter = ForecastListAdapter(result) {
13
startActivity(DetailActivity.ID to it.id,
14
DetailActivity.CITY_NAME to result.city)
15
}
16
forecastList.adapter = adapter
17
toolbarTitle = "${result.city} (${result.country})"
18
}
19
}
20
}
DetailActivity
also needs some layout modifications:


24 Interfaces and Delegation
119
1
2
xmlns:android="http://schemas.android.com/apk/res/android"
3
xmlns:tools="http://schemas.android.com/tools"
4
android:layout_width="match_parent"
5
android:layout_height="match_parent"
6
android:orientation="vertical">
7
8

9
10
11
android:layout_width="match_parent"
12
android:layout_height="wrap_content"
13
android:orientation="horizontal"
14
android:gravity="center_vertical"
15
android:paddingTop="@dimen/activity_vertical_margin"
16
android:paddingLeft="@dimen/activity_horizontal_margin"
17
android:paddingRight="@dimen/activity_horizontal_margin"
18
tools:ignore="UseCompoundDrawables">
19
....
20

21
22

The
toolbar
property is specified the same way.
DetailActivity
will initialise the toolbar too, set
the title and enable the up navigation icon:
1
override fun onCreate(savedInstanceState: Bundle?) {
2
super.onCreate(savedInstanceState);
3
setContentView(R.layout.activity_detail)
4
5

Download 1.04 Mb.

Do'stlaringiz bilan baham:
1   ...   63   64   65   66   67   68   69   70   ...   79




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling