1.在项目根目录下的build.gradle文件中,
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}
}
}
2.在entry模块的build.gradle文件中,
dependencies {
implementation('com.gitee.chinasoft_ohos:FlipViewPager.Draco:0.0.2-SNAPSHOT')
}
xml布局引用 FlipViewPager
<?xml version="1.0" encoding="utf-8"?>
<com.yalantis.flipviewpager.view.FlipViewPager
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_content"
ohos:width="match_parent"
ohos:orientation="vertical"
>
</com.yalantis.flipviewpager.view.FlipViewPager>
用自己的Adapter继承 BaseFlipAdapter,实现抽象的方法
public class FriendProvider extends BaseFlipAdapter {
public FriendProvider(Context context, List<Friend> items) {
super(context,items);
this.items = items;
this.context=context;
map = new HashMap<>(); //记录当前item滑动的位置
for (int a = 0; a < items.size(); a++) {
map.put(a, 1);
}
}
@Override
public Component getView(int position, Component component, ComponentContainer componentContainer) {
// ...
return component;
}
FriendsHolder属性说明
component | 说明 |
---|---|
DependentLayout left | 左边的布局 |
DependentLayout right | 右边的布局 |
DirectionalLayout center | 中间的布局 |
Image leftAvatar | 中间布局左边的图片 |
Image rightAvatar | 中间布局右边的图片 |
Text leftNickName | 左边布局的名字 |
Text rightNickName | 右边布局的名字 |
List leftInterests | 左边布局名称下面的分类文字 |
List rightInterests | 右边布局文字下面的分类文字 |
设置你的Provider ListContainer
ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_listContainer);
FriendProvider provider = new FriendProvider(this, Utils.friends);
listContainer.setItemProvider(provider);
listContainer.setLongClickable(false);
CodeCheck代码测试无异常
CloudTest代码测试无异常
火绒安全病毒安全检测通过
0.0.2-SNAPSHOT
Copyright 2015, Yalantis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарии ( 0 )