简体   繁体   English

如何在Android中制作类似Google io 2014应用的列表视图?

[英]how to make list views like google io 2014 app in android?

I want to create a list view layout with a image and title in it. 我想创建一个列表视图布局,其中包含图像和标题。 I want a layout like listview in google io 2014 app. 我想要Google io 2014应用中的类似于listview的布局。 It should be a tiled listview with some colour till the image gets loaded, after the image is loaded it should be shown in the upper half of the listview and title should be shown below with some background colour. 在加载图像之前,它应该是具有一定颜色的平铺列表视图,在加载图像之后,图像应显示在列表视图的上半部分,标题应在下方显示一些背景色。 I am attaching the screenshot of google io app here. 我在这里附上google io应用的屏幕截图。

在此处输入图片说明

Updated: If somebody can point me some template custom layout for this listview it would be helpful! 更新:如果有人可以为我指出该列表视图的一些模板自定义布局,那将有所帮助!

Create a custom list with all the needed controls in separate layout and inflate it using a custom adapter you can find a small example here 创建具有所有所需控件的单独列表的自定义列表,并使用自定义适配器对其进行充气,您可以在此处找到一个小示例

you could create a custom layout something like this 您可以创建类似这样的自定义布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:background="@drawable/images"
            android:layout_height="match_parent"
           />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:background="#862c10">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/white"
            android:textSize="15sp"
            android:layout_marginLeft="10dip"
            android:textStyle="bold"
            android:text="HTML5 everywhere how and why android users use the webplatform" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/white"
            android:textSize="15sp"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="10dip"
            android:text="Wed 5 2001" />

         <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/white"
            android:textSize="15sp"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="10dip"
            android:text="Steven roberts and mark robinson " />

    </LinearLayout>

</LinearLayout>

(this should not be the answer, but forgive me I could not add a comment, and actually I hope this will give him the answer). (这不应该是答案,但是请原谅我无法添加评论,实际上我希望这会给他答案)。

First of all I guess you didn't get on well with using ListView and Adapter in Android. 首先,我想您在Android中使用ListView和Adapter感觉不太好。 So I suggest you to read the following article first: 因此,我建议您首先阅读以下文章:

ListView tutorial 1 ListView教程1

ListView tutorial 2 ListView教程2

They will teach you how to use xml to define your custom row view. 他们将教您如何使用xml定义自定义行视图。 Then you will know how to use George Thomas's xml. 然后,您将知道如何使用George Thomas的xml。 Try how to implement the getView() method. 尝试如何实现getView()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM