通过string.xml向listview添加项目不会在android中更新设计,但可以在模拟器中工作

问题描述

我是android的新手。我尝试进行一个显示项目列表的简单活动,但是在我使用android:entries =“ @ array / options”将静态条目添加到布局中后,我的设计没有更新,但是我运行我的应用程序,可以在布局设计中看到项目而不是认项目。

这是我的xml代码

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <ImageView
            android:layout_width="200dp"
            android:layout_height="100dp"
            android:src="@drawable/starbuzz_logo"
            android:contentDescription="@string/starbuzz_logo" />
    
        <ListView
            android:id="@+id/list_options"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:entries="@array/options" />
    
    
    </LinearLayout>

这是我仿真器和设计的屏幕截图:

enter image description here

enter image description here

但是当使用约束布局时,我没有遇到这个问题。我想知道为什么。而且,这个问题是特定于listview还是约束布局具有某些优点?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)