iは、以下のXMLレイアウトファイル持っているだけでなく、は、XMLアンドロイドレイアウトの複数のインスタンス
あなたは罰金を期待して作成:
単に<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:orientation="vertical"
android:weightSum="1"
tools:showIn="@layout/activity_main">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:text=""
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignBottom="@+id/progressBar1" />
<ImageView
android:layout_width="match_parent"
android:layout_height="406dp"
android:id="@+id/img"
android:layout_below="@+id/textView" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_centerHorizontal="true" />
</RelativeLayout>
を、それがのTextViewとイメージビューが含まれています。
と私は次のように配列リストを受け取り、以下の機能を持っている:私は何をしたいが受信(学生)のループにある
public void DisplyOnTextView(List<Student> students) {
textView.setText(students.get(i).getDes());
new LoadImage().execute(students.get(i).getUrl().replaceAll("\\s+", ""));
}
のxmlレイアウトの新しいインスタンスを作成するための配列リストをどのこのような配列内の各レイアウトを保存するために、配列内の各学生のためのTextViewとImageViewのが含まれます:
int[] layouts = {R.layout.instance1, R.layout.instance2,...};
私のループは次のようになります。
for(int i=0;i<students.size(); i++){
// create new layout for student[i]
// create new textview for student[i]
//create new imageview for student[i]
// layouts[i] = the new created layout
}
これは可能ですか? 助けてください!
よろしく..
ないあなたがやろうとしているか確認してください、しかし、カスタムアダプタ – Yazan