Android: 具有多个 TextView 的相对布局。我应该使用哪种适配器来绑定数据?
Android: Relative layout with multiple TextViews. What kind of adapter should I to bind data?
注意:我没有使用ListView,所以我认为ArrayAdapter 不太适合。我有一个 RelativeLayout,其中一个 TextView 用于标题,另一个 TextView 位于 ScrollView 内用于描述。
我想从网络服务中获取数据并在此视图中显示标题和说明。我应该使用什么样的适配器?
绑定到 ArrayAdapter 似乎不合适。 CursorAdapter 也不合适,因为我没有从任何数据库获取数据。我将对来自 Web 服务的数据执行 AsyncTask。我想将数据绑定到 xml.
中的标题和定义 ID
<RelativeLayout
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"
tools:context=".MainActivity$PlaceholderFragment">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/title"
android:id="@+id/title"/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scroll"
android:layout_below="@+id/title">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/definition" />
</ScrollView>
<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/search"
android:layout_alignRight="@+id/title"/>
</RelativeLayout>
为什么要适配器?适配器 - 将集合的接口适配为该集合的查看器所需的接口。你好像没有这样的Viewer
注意:我没有使用ListView,所以我认为ArrayAdapter 不太适合。我有一个 RelativeLayout,其中一个 TextView 用于标题,另一个 TextView 位于 ScrollView 内用于描述。
我想从网络服务中获取数据并在此视图中显示标题和说明。我应该使用什么样的适配器?
绑定到 ArrayAdapter 似乎不合适。 CursorAdapter 也不合适,因为我没有从任何数据库获取数据。我将对来自 Web 服务的数据执行 AsyncTask。我想将数据绑定到 xml.
中的标题和定义 ID<RelativeLayout
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"
tools:context=".MainActivity$PlaceholderFragment">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/title"
android:id="@+id/title"/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scroll"
android:layout_below="@+id/title">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/definition" />
</ScrollView>
<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/search"
android:layout_alignRight="@+id/title"/>
</RelativeLayout>
为什么要适配器?适配器 - 将集合的接口适配为该集合的查看器所需的接口。你好像没有这样的Viewer