【发布时间】:2015-08-06 22:31:27
【问题描述】:
google place picker 中的示例代码使用 cardstream lib。这是一个开源库吗?如果是,我在哪里可以找到使用它的文档/指南?
github 网址:https://github.com/googlesamples/android-play-places/tree/master/PlacePicker
【问题讨论】:
google place picker 中的示例代码使用 cardstream lib。这是一个开源库吗?如果是,我在哪里可以找到使用它的文档/指南?
github 网址:https://github.com/googlesamples/android-play-places/tree/master/PlacePicker
【问题讨论】:
我认为 cardstream java 代码是一组很棒的 java 方法,可以在您的应用程序中使用。虽然没有用于 cardstream 的 javadocs,但您可以在代码本身中阅读方法的描述,因为方法描述写在各个方法之上。
不过,在您将其导入代码之前,我会确保您的应用可以使用 cardstream。
例如,如果我查看代码,我可以看到 cardstream 只是在操作一个线性布局,并没有真正将卡片添加到一个 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"/>
片段然后从这里拉出布局:
<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。
如果您的应用只想为线性布局中的几张卡片添加视图/删除视图,那么这个库非常棒。但大多数 Android 应用程序都希望添加卡片“流”,因此从效率的角度来看,将它们添加到 linearLayout 中并没有什么意义,因为这确实是低效的。
Android 上有一些可用的工具,例如 listview 或 recyclerview,它们经过优化可以提供更好的体验。
【讨论】: