- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中cn.youngkaaa.yviewpager.YPagerAdapter
类的一些代码示例,展示了YPagerAdapter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YPagerAdapter
类的具体详情如下:
包路径:cn.youngkaaa.yviewpager.YPagerAdapter
类名称:YPagerAdapter
[英]Base class providing the adapter to populate pages inside of a ViewPager. You will most likely want to use a more specific implementation of this, such as FragmentPagerAdapter or FragmentStatePagerAdapter.
When you implement a PagerAdapter, you must override the following methods at minimum:
PagerAdapter is more general than the adapters used for android.widget.AdapterView. Instead of providing a View recycling mechanism directly ViewPager uses callbacks to indicate the steps taken during an update. A PagerAdapter may implement a form of View recycling if desired or use a more sophisticated method of managing page Views such as Fragment transactions where each page is represented by its own Fragment.
ViewPager associates each page with a key Object instead of working with Views directly. This key is used to track and uniquely identify a given page independent of its position in the adapter. A call to the PagerAdapter method #startUpdate(ViewGroup) indicates that the contents of the ViewPager are about to change. One or more calls to #instantiateItem(ViewGroup,int)and/or #destroyItem(ViewGroup,int,Object) will follow, and the end of an update will be signaled by a call to #finishUpdate(ViewGroup). By the time #finishUpdate(ViewGroup) returns the views associated with the key objects returned by #instantiateItem(ViewGroup,int) should be added to the parent ViewGroup passed to these methods and the views associated with the keys passed to #destroyItem(ViewGroup,int,Object)should be removed. The method #isViewFromObject(View,Object) identifies whether a page View is associated with a given key object.
A very simple PagerAdapter may choose to use the page Views themselves as key objects, returning them from #instantiateItem(ViewGroup,int)after creation and adding them to the parent ViewGroup. A matching #destroyItem(ViewGroup,int,Object) implementation would remove the View from the parent ViewGroup and #isViewFromObject(View,Object)could be implemented as return view == object;
.
PagerAdapter supports data set changes. Data set changes must occur on the main thread and must end with a call to #notifyDataSetChanged() similar to AdapterView adapters derived from android.widget.BaseAdapter. A data set change may involve pages being added, removed, or changing position. The ViewPager will keep the current page active provided the adapter implements the method #getItemPosition(Object).
[中]基类提供用于填充ViewPager内部页面的适配器。您很可能希望使用更具体的实现,例如FragmentPagerAdapter或FragmentStatePagerAdapter。
实现PagerAdapter时,必须至少覆盖以下方法:
*#实例化项(视图组,int)
*#destroyItem(视图组、int、对象)
*#getCount()
*#isViewFromObject(视图,对象)
PagerAdapter比用于android的适配器更通用。小装置。AdapterView。ViewPager没有直接提供视图循环机制,而是使用回调来指示更新过程中采取的步骤。如果需要,PagerAdapter可以实现一种形式的视图循环,或者使用更复杂的方法来管理页面视图,例如片段事务,其中每个页面都由自己的片段表示。
ViewPager将每个页面与一个键对象关联,而不是直接使用视图。此键用于跟踪和唯一标识给定页面,而不受其在适配器中的位置影响。调用PagerAdapter方法#startUpdate(ViewGroup)表示ViewPager的内容即将更改。随后将有一个或多个对#InstanceItem(ViewGroup,int)和/或#destroyItem(ViewGroup,int,Object)的调用,并通过对#finishUpdate(ViewGroup)的调用发出更新结束的信号。当#finishUpdate(ViewGroup)返回与#InstanceItem(ViewGroup,int)返回的键对象相关联的视图时,应将其添加到传递给这些方法的父视图组中,并删除与传递给#destroyItem(ViewGroup,int,Object)的键相关联的视图。方法#isViewFromObject(视图,对象)标识页面视图是否与给定的键对象关联。
一个非常简单的PagerAdapter可以选择将页面视图本身用作关键对象,在创建后从#InstanceItem(ViewGroup,int)返回它们,并将它们添加到父视图组中。匹配的#destroyItem(ViewGroup,int,Object)实现将从父视图组中删除视图,#isViewFromObject(View,Object)可以实现为return view == object;
。
PagerAdapter支持数据集更改。数据集更改必须发生在主线程上,并且必须以调用#notifyDataSetChanged()结束,类似于从android派生的AdapterView适配器。小装置。BaseAdapter。数据集更改可能涉及页面的添加、删除或位置更改。如果适配器实现#getItemPosition(Object)方法,ViewPager将保持当前页面处于活动状态。
代码示例来源:origin: open-android/ViewPager
/**
* Remove a page for the given position. The adapter is responsible
* for removing the view from its container, although it only must ensure
* this is done by the time it returns from {@link #finishUpdate(ViewGroup)}.
*
* @param container The containing View from which the page will be removed.
* @param position The page position to be removed.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
*/
public void destroyItem(ViewGroup container, int position, Object object) {
destroyItem((View) container, position, object);
}
代码示例来源:origin: open-android/ViewPager
/**
* Called when the a change in the shown pages has been completed. At this
* point you must ensure that all of the pages have actually been added or
* removed from the container as appropriate.
*
* @param container The containing View which is displaying this adapter's
* page views.
*/
public void finishUpdate(ViewGroup container) {
finishUpdate((View) container);
}
代码示例来源:origin: open-android/ViewPager
private int getAdapterCount() {
if (isCirculatory) {
return mAdapterCirculatoryCount;
} else {
return mAdapter.getCount();
}
}
代码示例来源:origin: open-android/ViewPager
ItemInfo addNewItem(int position, int index) {
int newPos = position % mAdapter.getCount();
Log.d(TAG, "addNewItem newPos=>" + newPos + ",position=>" + position);
if (newPos == 0) {
mCurrentStartPos = position;
Log.d(TAG, "addNewItem mCurrentStartPos=>" + mCurrentStartPos);
}
ItemInfo ii = new ItemInfo();
ii.position = position;
ii.object = mAdapter.instantiateItem(this, newPos);
ii.widthFactor = mAdapter.getPageWidth(newPos);
if (index < 0 || index >= mItems.size()) {
mItems.add(ii);
} else {
mItems.add(index, ii);
}
return ii;
}
代码示例来源:origin: open-android/ViewPager
/**
* 根据传入的position来构造一个ItemInfo对象的实例 然后加入到mItems中去
*
* @param position
* @param index
* @return
*/
ItemInfo addNewItem(int position, int index) {
ItemInfo ii = new ItemInfo();
ii.position = position;
ii.object = mAdapter.instantiateItem(this, position);
ii.widthFactor = mAdapter.getPageWidth(position);
if (index < 0 || index >= mItems.size()) {
mItems.add(ii);
} else {
mItems.add(index, ii);
}
return ii;
}
代码示例来源:origin: open-android/ViewPager
mAdapter.startUpdate(this);
final int N = mAdapter.getCount();
mAdapter.destroyItem(this, pos, ii.object);
mAdapter.destroyItem(this, pos, ii.object);
ii = itemIndex < mItems.size() ? mItems.get(itemIndex) : null;
mAdapter.setPrimaryItem(this, mCurItem, curItem != null ? curItem.object : null);
mAdapter.finishUpdate(this);
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
代码示例来源:origin: open-android/ViewPager
mAdapter.setViewPagerObserver(null);
mAdapter.startUpdate(this);
for (int i = 0; i < mItems.size(); i++) {
final ItemInfo ii = mItems.get(i);
mAdapter.destroyItem(this, ii.position, ii.object);
mAdapter.finishUpdate(this);
mItems.clear();
removeNonDecorViews();
mObserver = new PagerObserver();
mAdapter.setViewPagerObserver(mObserver);
mPopulatePending = false;
final boolean wasFirstLayout = mFirstLayout;
mFirstLayout = true;
mExpectedAdapterCount = mAdapter.getCount();
if (mRestoredCurItem >= 0) {
mAdapter.restoreState(mRestoredAdapterState, mRestoredClassLoader);
if (isVertical) {
setCurrentItemInternalVertical(mRestoredCurItem, false, true);
代码示例来源:origin: open-android/ViewPager
void dataSetChanged() {
final int adapterCount = mAdapter.getCount();
mExpectedAdapterCount = adapterCount;
boolean needPopulate = mItems.size() < mOffscreenPageLimit * 2 + 1
for (int i = 0; i < mItems.size(); i++) {
final ItemInfo ii = mItems.get(i);
final int newPos = mAdapter.getItemPosition(ii.object);
mAdapter.startUpdate(this);
isUpdating = true;
mAdapter.destroyItem(this, ii.position, ii.object);
needPopulate = true;
mAdapter.finishUpdate(this);
代码示例来源:origin: open-android/ViewPager
offset += mAdapter.getPageWidth(pos) + marginOffset;
pos++;
offset -= mAdapter.getPageWidth(pos) + marginOffset;
pos--;
offset -= mAdapter.getPageWidth(pos--) + marginOffset;
final ItemInfo ii = mItems.get(i);
while (pos < ii.position) {
offset += mAdapter.getPageWidth(pos++) + marginOffset;
代码示例来源:origin: open-android/ViewPager
private void calculatePageOffsetsVertical(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
final int N = mAdapter.getCount();
final int height = getClientHeight();
final float marginOffset = height > 0 ? (float) mPageMargin / height : 0;
offset += mAdapter.getPageWidth(pos) + marginOffset;
pos++;
offset -= mAdapter.getPageWidth(pos) + marginOffset;
pos--;
offset -= mAdapter.getPageWidth(pos--) + marginOffset;
final ItemInfo ii = mItems.get(i);
while (pos < ii.position) {
offset += mAdapter.getPageWidth(pos++) + marginOffset;
代码示例来源:origin: open-android/ViewPager
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
ss.position = mCurItem;
if (mAdapter != null) {
ss.adapterState = mAdapter.saveState();
}
return ss;
}
代码示例来源:origin: open-android/ViewPager
ItemInfo infoForChild(View child) {
for (int i = 0; i < mItems.size(); i++) {
ItemInfo ii = mItems.get(i);
if (mAdapter.isViewFromObject(child, ii.object)) {
return ii;
}
}
return null;
}
代码示例来源:origin: open-android/ViewPager
@Override
public void onRestoreInstanceState(Parcelable state) {
if (!(state instanceof SavedState)) {
super.onRestoreInstanceState(state);
return;
}
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
if (mAdapter != null) {
mAdapter.restoreState(ss.adapterState, ss.loader);
if (isVertical) {
setCurrentItemInternalVertical(ss.position, false, true);
} else {
setCurrentItemInternalHorizontal(ss.position, false, true);
}
} else {
mRestoredCurItem = ss.position;
mRestoredAdapterState = ss.adapterState;
mRestoredClassLoader = ss.loader;
}
}
代码示例来源:origin: open-android/ViewPager
/**
* Called to inform the adapter of which item is currently considered to
* be the "primary", that is the one show to the user as the current page.
*
* @param container The containing View from which the page will be removed.
* @param position The page position that is now the primary.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
*/
public void setPrimaryItem(ViewGroup container, int position, Object object) {
setPrimaryItem((View) container, position, object);
}
代码示例来源:origin: open-android/ViewPager
/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate(ViewGroup)}.
*
* @param container The containing View in which the page will be shown.
* @param position The page position to be instantiated.
* @return Returns an Object representing the new page. This does not
* need to be a View, but can be some other container of the page.
*/
public Object instantiateItem(ViewGroup container, int position) {
return instantiateItem((View) container, position);
}
代码示例来源:origin: open-android/ViewPager
mAdapter.startUpdate(this);
mAdapter.destroyItem(this, pos, ii.object);
itemIndex--;
curIndex--;
mAdapter.destroyItem(this, pos, ii.object);
ii = itemIndex < mItems.size() ? mItems.get(itemIndex) : null;
mAdapter.setPrimaryItem(this, mCurItem, curItem != null ? curItem.object : null);
mAdapter.finishUpdate(this);
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
代码示例来源:origin: open-android/ViewPager
Log.d(TAG, "setAdapter() in");
if (mAdapter != null) {
mAdapter.setViewPagerObserver(null);
mAdapter.startUpdate(this);
for (int i = 0; i < mItems.size(); i++) {
final ItemInfo ii = mItems.get(i);
mAdapter.destroyItem(this, ii.position, ii.object);
mAdapter.finishUpdate(this);
mItems.clear();
removeNonDecorViews();
mObserver = new PagerObserver();
mAdapter.setViewPagerObserver(mObserver);
mPopulatePending = false;
final boolean wasFirstLayout = mFirstLayout;
Log.d(TAG, "setAdapter() mCurItem2=>" + mCurItem);
if (mRestoredCurItem >= 0) {
mAdapter.restoreState(mRestoredAdapterState, mRestoredClassLoader);
if (isVertical) {
setCurrentItemInternalVertical(mRestoredCurItem, false, true);
代码示例来源:origin: open-android/ViewPager
for (int i = 0; i < mItems.size(); i++) {
final YViewPager.ItemInfo ii = mItems.get(i);
final int newPos = mAdapter.getItemPosition(ii.object);
mAdapter.startUpdate(this);
isUpdating = true;
mAdapter.destroyItem(this, ii.position, ii.object);
needPopulate = true;
mAdapter.finishUpdate(this);
代码示例来源:origin: open-android/ViewPager
offset += mAdapter.getPageWidth(pos) + marginOffset;
pos++;
offset -= mAdapter.getPageWidth(pos) + marginOffset;
pos--;
offset -= mAdapter.getPageWidth(pos--) + marginOffset;
final ItemInfo ii = mItems.get(i);
while (pos < ii.position) {
offset += mAdapter.getPageWidth(pos++) + marginOffset;
代码示例来源:origin: open-android/ViewPager
final int N = mAdapter.getCount();
final int width = getClientWidth();
final float marginOffset = width > 0 ? (float) mPageMargin / width : 0;
offset += mAdapter.getPageWidth(pos) + marginOffset;
pos++;
offset -= mAdapter.getPageWidth(pos) + marginOffset;
pos--;
offset -= mAdapter.getPageWidth(pos--) + marginOffset;
final ItemInfo ii = mItems.get(i);
while (pos < ii.position) {
offset += mAdapter.getPageWidth(pos++) + marginOffset;
我在 www.example.com 上托管了一个 heroku 应用程序。 我有为该地址(www.example.com)颁发的证书。我已经根据 heroku 文档成功安装了证书。 可是,我怎么有个
我是 php 的新手,我正在尝试使用 ssl 连接到 gloudsql证书。但它给我一个关于 CN 的错误。这是什么意思我的代码中缺少什么?我的项目名称是 wiiboardtest 和我的实例名称是
我正在使用 haxe 的 Http 类(编译为 php)通过 https 将 request() 发送到 AWS。这是一个使用 haxe-aws 库 ( https://github.com/Blan
对于 Microsoft Exchange,以下字符串的格式是什么? /o=First Organization/ou=First Administrative Group/cn=Recipients
我们正在尝试向新成员(member)发送自动回复邮件。我们在同一台服务器上的其他站点上使用相同的配置,没有问题。发送电子邮件后,返回以下错误: stream_socket_enable_crypto(
我在 Laravel 从事邮件工作。我有以下配置。 MAIL_DRIVER=smtp MAIL_HOST=smtp.sendgrid.net MAIL_PORT=587 MAIL_USERNAME=*
我们在端口 3306 上有一个带有 mysql 的服务器。我们有证书和 key ,我们尝试连接到这个服务器。但是我们看到这样的问题: Peer certificate CN='SomeName' di
本文整理了Java中cn.youngkaaa.yviewpager.YPagerAdapter类的一些代码示例,展示了YPagerAdapter类的具体用法。这些代码示例主要来源于Github/Sta
探秘Python的奇妙之旅 曾经有一个人类,他为了追求知识的边界而踏上了一段令人神往的旅程。在他的旅途中,他遇见了一个神奇的生物,被称之为“爬虫”。这个名字听起来是多么的引人入胜,宛如一只忍者般幽灵般
我正在使用数字证书并将其存储在 KV 中。我在私有(private)端点后面有一个前端 Web 应用程序。我想将一个友好名称关联到 Web 应用程序,并将该名称与应用程序网关一起使用,这样当人们使用友
我正在尝试遍历计算机列表并检索每台计算机的模型。当我使用Write-Output打印每台计算机的名称时,这正是我所期望的(只是名称)。但是,当我尝试使用wmic命令获取模型时,似乎正在使用“CN =
这是一个有点愚蠢的设置,但这是我现在正在查看的内容: 我正在学习 Kubernetes 我想将自定义代码推送到我的 Kubernetes 集群,这意味着代码必须作为 Docker 镜像提供,可从 获得
在 C# 中,我像这样创建到服务器的 SSL 连接: var hostname = "www.example.com"; var client = new TcpClient(hostname, 44
我在使用 CentOS 6 的同一台服务器上有多个虚拟主机。运行 sudo ./path/to/certbot-auto --apache 后,我已经成功地为网站安装了证书 https://domai
我想制作一个通用命令,该命令在运行时应将证书的 CN 值作为执行命令的主机名。 我目前使用的命令如下 openssl req -sha256 -new -key $HOSTNAME.key -out
这个问题在这里已经有了答案: Writing a SSL Checker using Java (2 个答案) 关闭 5 年前。
通过对复发的研究,我试图解决这种复发你能帮我查一下吗 public static int java(int N) { if (N == 1) return 1; return (jav
public static int test(int N) { if (N == 1) return 1; return (3 * (test(N/2) + test(N/2)) + f(N)
我今天正在阅读 CLRS,以更好地理解归并排序的复杂性。我看到一行内容是“其中常量 c 表示解决大小为 1 的问题所需的时间以及划分和组合步骤中每个数组元素的时间。”我知道作者所说的大小为 1 的问题
我想从证书主题字段中检索一个字符串,但只是它的 CN 值。 获取我使用的整个字符串: Enumeration enumeration = ks.aliases(); while (enumeratio
我是一名优秀的程序员,十分优秀!