CardScrollView

در سطح API XE12 اضافه شده است

View که نماهای کودکان در حال پیمایش افقی را نشان می دهد که به آن کارت می گویند.

کارت ها از CardScrollAdapter که با CardScrollView مرتبط است می آیند. هر کارت به صورت بصری نشان دهنده یک آیتم Object خاص است.

برای اطلاعات بیشتر به اسکرول کارت ها در فعالیت ها مراجعه کنید.

استفاده عمومی

  1. مجموعه ای از کارت ها را با استفاده از سلسله مراتب نمای استاندارد یا کلاس CardBuilder بسازید.
  2. برای تامین مجموعه کارت ها به CardScrollView یک CardScrollAdapter پیاده سازی کنید. هر کارت یک شناسه Object منحصر به فرد دارد و نشان دهنده یک آیتم Object خاص است.
  3. نمای محتوای فعالیت خود را به صورت CardScrollView تنظیم کنید یا از CardScrollView در یک طرح بندی استفاده کنید.

مدیریت پیمایش و تعامل

CardScrollView شما را با رابط های شنونده زیر که از AdapterView به ارث رسیده اند مطلع می کند:

  • AdapterView.OnItemSelectedListener - یک مورد پس از پایان یافتن پیمایش کاربر در لیست انتخاب می شود و روی یک مورد مستقر می شود.
  • AdapterView.OnItemClickListener - زمانی که کاربر روی یک مورد انتخاب شده ضربه می زند و رها می کند، روی یک مورد کلیک می شود.
  • AdapterView.OnItemLongClickListener ) - زمانی که کاربر روی یک مورد انتخاب شده ضربه می زند، نگه می دارد و رها می کند، روی یک مورد طولانی کلیک می شود.

کلاس های تو در تو
enum CardScrollView.Animation نوع انیمیشن مورد استفاده برای پیمایش، درج یا حذف کارت را تعریف می کند.
ثابت های ارثی
فیلدهای ارثی
سازندگان عمومی
CardScrollView ( زمینه زمینه)
CardScrollView ( زمینه زمینه، AttributeSet attrs، int defStyle)
روش های عمومی
خالی
بولی
متحرک (موقعیت int، CardScrollView.Animation animationType)
خالی
CardScrollAdapter
طولانی
بین المللی
چشم انداز
بولی
بولی
بولی
onKeyDown (int keyCode، رویداد KeyEvent )
خالی
onWindowFocusChanged (بولی دارایWindowFocus)
خالی
setAdapter (آداپتور CardScrollAdapter )
خالی
setEmptyView ( مشاهده نمای خالی)
خالی
setHorizontalScrollBarEnabled (فعال کردن بولین)
خالی
setSelection (موقعیت int)
روش های محافظت شده
بولی
بولی
خالی
خالی
onLayout (بولی تغییر کرد، int چپ، int بالا، int راست، int پایین)
خالی
onVisibilityChanged ( مشاهده تغییرات نمای، دید بین‌المللی)
روش های ارثی

Public Constructors

در سطح API XE12 اضافه شده است

public CardScrollView ( Context context)

در سطح API XE12 اضافه شده است

public CardScrollView ( Context context, AttributeSet attrs)

در سطح API XE12 اضافه شده است

public CardScrollView ( Context context, AttributeSet attrs, int defStyle)

Public Methods

در سطح API XE12 اضافه شده است

public void activate ()

Tells the CardScrollView to activate and be ready for display. TODO(ajcbik): investigate if we can replace [de]activate with focus events, see b/17574566 request.

Added in API level XE21

public boolean animate (int position, CardScrollView.Animation animationType)

Animates for card at given position, where animationType should be one of:

  • NAVIGATION : moves to given card from any position, regular navigation,
  • INSERTION : moves to given card, which appears into view, after insertion,
  • DELETION : given card disappears from view, if selected, after deletion.
The animation is skipped if the scroller is deactivated, if a prior autonomous animation is still ongoing, or if the position is invalid. A deletion animation only occurs if the deleted card is currently selected.

The insertion and deletion animation should be used after doing the corresponding mutation in CardScrollAdapter . The animation will call the notifyDataSetChanged() on the adapter at the proper moment in the animation, even when skipped or terminated early.

Sample usage:

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

مولفه های
position of the card involved in the animation
animationType controls the type of animation to use
Returns
  • whether animation was started
در سطح API XE12 اضافه شده است

public void deactivate ()

Tells the CardScrollView to deactivate; it will not be displayed until after activate() is called again.

در سطح API XE12 اضافه شده است

public CardScrollAdapter getAdapter ()

public long getSelectedItemId ()

در سطح API XE12 اضافه شده است

public int getSelectedItemPosition ()

در سطح API XE12 اضافه شده است

public View getSelectedView ()

در سطح API XE12 اضافه شده است

public boolean isActivated ()

public boolean isHorizontalScrollBarEnabled ()

public boolean onKeyDown (int keyCode, KeyEvent event)

public void onWindowFocusChanged (boolean hasWindowFocus)

در سطح API XE12 اضافه شده است

public void setAdapter ( CardScrollAdapter adapter)

public void setEmptyView ( View emptyView)

The setEmptyView(View) is unsupported by the CardScrollView .

To get proper animation and tuggable behavior, use an adapter with a single empty view for empty data sets instead.

public void setHorizontalScrollBarEnabled (boolean enable)

در سطح API XE12 اضافه شده است

public void setSelection (int position)

Protected Methods

protected boolean awakenScrollBars ()

Awakens the horizontal scrollbar, if any.

protected boolean dispatchGenericFocusedEvent ( MotionEvent event)

protected void initializeScrollbars ( TypedArray a)

در سطح API XE12 اضافه شده است

protected void onLayout (boolean changed, int left, int top, int right, int bottom)

protected void onVisibilityChanged ( View changedView, int visibility)