如何在Android Studio

时间:2016-06-19 15:16:48

标签: android listview android-studio

我对Android Studio很新,对于我的应用程序,我需要创建一个由以下单元格组成的自定义ListView:

  • 2x textView
  • 不可修改的评级(星级)
  • 一个imageView

细胞看起来像这样:

My ListView

如果您使用Android Studio中的设计界面而不是xml编辑器向我展示方式,我将非常感激。

到目前为止,我创建了一个简单的listView,但我不知道如何自定义它。这是xml代码:

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="dancam.com.chords.TabMainActivity">

<ListView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/listView"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true" />
</RelativeLayout>

2 个答案:

答案 0 :(得分:3)

希望您现在能够理解和发展您的设计。

enter image description here

答案 1 :(得分:0)

您需要为每一行添加视图。

  1. 在布局资源中添加row.xml。
  2. getView inflate row.xml中为listview创建自定义适配器。 这是example
  3. 如果您需要更灵活的实施,请考虑 使用RecyclerView,指导here

    希望有所帮助