在google place picker示例代码中使用cardstream

时间:2015-05-25 18:31:38

标签: google-places-api

Google地方选择器中的示例代码使用了cardstream lib。这是一个开源库,如果是这样,我在哪里找到使用它的文档/指南?

github网址:https://github.com/googlesamples/android-play-places/tree/master/PlacePicker

1 个答案:

答案 0 :(得分:1)

我认为cardstream java代码是一组很棒的java方法,可以在你的应用程序中使用。虽然没有用于cardstream的javadoc,但您可以在代码本身中阅读该方法的描述,因为方法描述是在各个方法之上编写的。

但是,我会确保您的应用在将其导入代码之前可以使用cardstream。

例如,如果我查看代码,我可以看到cardstream正在操纵linearLayout而不是真正将卡添加到recyclerview / listview。

mainactivity显示此处https://github.com/googlesamples/android-play-places/blob/master/PlacePicker/Application/src/main/res/layout/activity_main.xml的布局:

<fragment
    android:id="@+id/fragment_cardstream"
    android:name="com.example.google.playservices.placepicker.cardstream.CardStreamFragment"
    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"
    tools:layout="@layout/cardstream"/>

然后片段从这里拉出布局:

https://github.com/googlesamples/android-play-places/blob/master/PlacePicker/Application/src/main/res/layout/cardstream.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <com.example.google.playservices.placepicker.cardstream.CardStreamLinearLayout
        style="@style/CardStream"
        android:id="@+id/card_stream"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</ScrollView>

片段使用的布局是cardStreamLinearLayout。

如果您的应用只想为linearLayout中的几张卡添加Views / removeView,那么这个库非常棒。但是大多数Android应用程序都希望添加一个“流”卡片,因此从效率角度来看,将它们添加到linearLayout上实际上并没有意义,因为这实际上是低效的。

android上有一些工具,例如listview或recyclerview,可以提供更好的体验,因为它们已经过优化。