android中的MVC从参考资料填充listview
似乎它们应该是一种静态填充列表视图的方法,其中包含一组按钮,这些按钮只使用xml,可能使用android:resource或android:entries。我更喜欢与主布局分开的资源xml文件。如果我理解MVC,那么视图更像是一个静态的东西,因为控制器具有视图的侦听器并对视图进行更改。我不知道字符串数组是否可以容纳按钮对象,或者我哪里出错了。有什么建议吗?哦,所有的按钮都应该有相同的属性,但这可能是另一个问题android中的MVC从参考资料填充listview,android,xml,listview,Android,Xml,Listview,似乎它们应该是一种静态填充列表视图的方法,其中包含一组按钮,这些按钮只使用xml,可能使用android:resource或android:entries。我更喜欢与主布局分开的资源xml文件。如果我理解MVC,那么视图更像是一个静态的东西,因为控制器具有视图的侦听器并对视图进行更改。我不知道字符串数组是否可以容纳按钮对象,或者我哪里出错了。有什么建议吗?哦,所有的按钮都应该有相同的属性,但这可能是另一个问题 <FrameLayout xmlns:android="http://schem
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/MainFrameLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
package="com.union.doogie"
android:animateLayoutChanges="true"
android:layoutMode="opticalBounds"
android:visibility="visible"
tools:context=".MainActivity" >
<ListView
android:id="@+id/listViewmain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@buttons/Buttons" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
</ListView>
</FrameLayout>
Android允许您通过@+ID/your_ID符号在布局文件中动态定义用户界面组件的ID 要控制ID,还可以在/res/values文件夹中创建一个名为IDs.xml的文件,并在此文件中定义所有ID
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="button1" type="id"/>
</resources>
这允许您直接在布局文件中使用ID
<ListView
android:id="@+id/listViewmain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@id/button1" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
</ListView>