第一行代碼(第2版):菜雞踩坑系列----14.4遍歷省市縣三級列表的功能

第一行代碼 14.4遍歷省市縣三級列表的功能

終於成功實現了這個功能,相當的開心。
在這裏弄了很久,因爲始終無法實現是三個頁面的成功展示。
問題應該在我,搬抄代碼時存在一些小問題。

需要注意一點: 如果直接訪問網址會出現加載失敗的提示。

具體原因不清楚,應該是android爲了使用戶更加安全,
我們需要在配置文件中添加一行

    android:usesCleartextTraffic="true"

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.coolweather.android">
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:name="org.litepal.LitePalApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

其他代碼和書上一致。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章