CardScrollView

在 API 级别 XE12 中引入

一个 View,用于显示水平滚动的子视图; 也称为卡片

这些卡片来自CardScrollAdapter CardScrollView。每张卡片在视觉上代表一个特定的 Object 项。

请参阅 在活动中滚动卡片以了解详情。

常规用法

  1. 使用标准视图层次结构或 CardBuilder 类构建一组卡片。
  2. 实现 CardScrollAdapter 以将一组卡片提供给 CardScrollView。每张卡都有一个唯一的 Object 标识符 表示特定的 Object 项。
  3. 将 activity 的内容视图设置为 CardScrollView,或使用 CardScrollView

处理滚动和交互

CardScrollView 会使用以下监听器接口通知您 继承自 AdapterView

嵌套类
枚举 CardScrollView.Animation 定义用于导航到、插入或删除卡片的动画类型。
继承的常量
继承的字段
公共构造函数
CardScrollView上下文上下文)
CardScrollView上下文上下文,AttributeSet 属性)
CardScrollView(Context 上下文, AttributeSet 属性, int defStyle)
公共方法
无效
布尔值
animate(int position, CardScrollView.Animation animationType)
无效
CardScrollAdapter
长整型
整数
查看
布尔值
isActivatedisActivated()
布尔值
布尔值
onKeyDown(整数键代码,KeyEvent 事件)
无效
onWindowFocusChanged(布尔值 hasWindowFocus)
无效
setAdapterCardScrollAdapter 适配器)
无效
setEmptyView(View emptyView)
无效
setHorizontalScrollBarEnabled(布尔值启用)
无效
setSelection(整型位置)setSelection
受保护的方法
布尔值
布尔值
无效
无效
onLayout(布尔值已更改, int left, int top, int right, int bottom)
无效
onVisibilityChanged(View changedView, int visibility)
继承的方法

公共构造函数

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 CardScrollView 上下文上下文)

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 CardScrollView 上下文上下文,AttributeSet 属性)

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 CardScrollView (Context context, AttributeSet属性, int defStyle)

公共方法

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 无效 启用 ()

指示 CardScrollView 激活并准备好显示。 TODO(ajcbik):调查我们是否可以用焦点事件替换 [de]activate。

在 API 级别 XE21 中添加

<ph type="x-smartling-placeholder"></ph> 公开 布尔值 添加动画 (int position, CardScrollView.Animation animationType)

为卡片在指定位置添加动画效果,其中 animationType 应为以下项之一:

  • NAVIGATION: 从任意位置移动到指定卡片、常规导航
  • INSERTION: 该卡片会移到可见的指定卡片中 插入卡片后
  • DELETION: 如果选中该卡片,则会在删除后从视图中消失。
。 如果滚动条已停用,并且先前的自主动画 或排名无效,则会发生该错误。仅当已删除的 卡当前已选中。

在执行相应的变更之后应使用插入和删除动画 在 CardScrollAdapter 中。动画将在notifyDataSetChanged() 适配器。

用法示例:

 .... insert card at p-th position in adapter ....
 animate(p, INSERTION);    // calls notifyDataSetChanged() on adapter
 

参数
排名 动画中涉及的卡片
animationType 控制要使用的动画类型
返回
  • 是否已启动动画
在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 无效 停用 ()

指示 CardScrollView 停用;它要等到 系统再次调用 activate()

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 CardScrollAdapter getAdapter ()

<ph type="x-smartling-placeholder"></ph> 公开 长整型 getSelectedItemId ()

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 整数 getSelectedItemPosition ()

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 查看 getSelectedView ()

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 布尔值 isActivated ()

<ph type="x-smartling-placeholder"></ph> 公开 布尔值 isHorizontalScrollBarEnabled ()

<ph type="x-smartling-placeholder"></ph> 公开 布尔值 onKeyDown (int keyCode, KeyEvent 事件)

<ph type="x-smartling-placeholder"></ph> 公开 无效 onWindowFocusChanged (布尔值 hasWindowFocus)

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 无效 setAdapter CardScrollAdapter 适配器)

<ph type="x-smartling-placeholder"></ph> 公开 无效 setEmptyView 查看 emptyView)

setEmptyView(View)不受以下格式的支持: CardScrollView

要获得适当的动画和可拖动行为,请使用具有单个 显示空白数据集。

<ph type="x-smartling-placeholder"></ph> 公开 无效 setHorizontalScrollBarEnabled (布尔值启用)

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 公开 无效 setSelection (整数位置)

受保护的方法

<ph type="x-smartling-placeholder"></ph> 受保护 布尔值 awakenScrollBars ()

唤醒水平滚动条(如果有)。

<ph type="x-smartling-placeholder"></ph> 受保护 布尔值 dispatchGenericFocusedEvent MotionEvent 事件)

<ph type="x-smartling-placeholder"></ph> 受保护 无效 initializeScrollbars (TypedArray a)

在 API 级别 XE12 中引入

<ph type="x-smartling-placeholder"></ph> 受保护 无效 onLayout (布尔值已更改, int left, int top, int right, int bottom)

<ph type="x-smartling-placeholder"></ph> 受保护 无效 onVisibilityChanged 视图 changedView、int visibility)