1

下の画像のようなユーザーインターフェイスを設計する必要があるAndroidプロジェクトに取り組んでいます-

ここに画像の説明を入力

上に としてテキストを表示する必要がありStudent App、その下には のさまざまなオブジェクトがありStudentます。私が持っていると仮定すると、各学生10 Studentsにあるとします。10 rows各行の左側に画像があり、中央にテキストがあり、右側に別のthree text.

私はいくつかの進歩を遂げ、以下のコードを持っています。しかし、それは私がイメージで探している方法とは正確ではありません。

<ImageView
        android:id="@+id/icon"
        android:src="@drawable/action_eating"
        android:layout_width="60dp"
        android:layout_height="60dp" />
<LinearLayout
        android:orientation="vertical"
        android:layout_gravity="center_vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp" >
    <TextView
            android:id="@+id/text1"
            android:text="test"
            android:textColor="#333"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="18sp" />
    <TextView
            android:id="@+id/text2"
            android:text="test2"
            android:textColor="#6699CC"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp" />
</LinearLayout>

そして、そのリストをスクロール可能にする必要があります。

誰でもこれで私を助けることができますか? 助けてくれてありがとう。

4

2 に答える 2

1

テーブルビューを使用して列を作成する方法

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <!-- 2 columns -->
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" >

        <TextView
            android:id="@+id/textView1"
            android:text="Column 1"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <Button
            android:id="@+id/button1"
            android:text="Column 2" />
    </TableRow>

    <!-- edittext span 2 column -->
    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" >

        <EditText
            android:id="@+id/editText1"
            android:layout_span="2"
            android:text="Column 1 &amp; 2" />
    </TableRow>

    <!-- just draw a red line -->
    <View
        android:layout_height="2dip"
        android:background="#FF0000" />

    <!-- 3 columns -->
    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" >

        <TextView
            android:id="@+id/textView2"
            android:text="Column 1"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <Button
            android:id="@+id/button2"
            android:text="Column 2" />

        <Button
            android:id="@+id/button3"
            android:text="Column 3" />
    </TableRow>

    <!-- display this button in 3rd column via layout_column(zero based) -->
    <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" >

        <Button
            android:id="@+id/button4"
            android:layout_column="2"
            android:text="Column 3" />
    </TableRow>

    <!-- display this button in 2nd column via layout_column(zero based) -->
    <TableRow
        android:id="@+id/tableRow5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" >

        <Button
            android:id="@+id/button5"
            android:layout_column="1"
            android:text="Column 2" />
    </TableRow>

</TableLayout>
于 2013-03-08T06:54:38.077 に答える
0

学生リストには ListView が必要で、から派生しArrayAdapter<Student>てオーバーライドするカスタム クラスを作成しますgetView()。学生オブジェクトのリストがアダプターに渡され、アダプターが ListView に渡されます。クラスでこれを行っていて、学習が目的である場合、これは慣れるのに最適な内容であり、プロの Android 開発にとって非常に実用的です。余分な功績として、Google I/O 2012 の「World of ListView」という YouTube のビデオを見つけて、他のクラスメートよりも速くリストを作成してください。

于 2013-03-08T06:54:48.297 に答える