# MainActivity 抓不到布局檔的 ID ## 問題描述 在 `activity_Main.xml` 已輸入 ID,在 `MainActivity` 卻報錯。 ```xml <ListView android:id="@+id/myListView" > . . . ```  ## 解決方案 在 `build.gradle (:app)` 檔案裡加入以下程式: ```kotlin apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' ``` 並確認在 `MainActivity.kt` 中有這行: ```kotlin import kotlinx.android.synthetic.main.activity_main.* ``` ###### tags: `Kotlin` `除錯記錄` `Android Studio`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up