# PopupListView **Repository Path**: leelxr/PopupListView ## Basic Information - **Project Name**: PopupListView - **Description**: listview点击弹出内容 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-11-08 - **Last Updated**: 2024-11-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PopupListView ### 功能介绍 强大的listview,可以点击listview中的哪个item,在item view下弹出显示内部视图! ### 效果演示 ![](image/popuplistview.gif) ### 安装教程 方式一: 1. 下载PopupListView的模块代码添加到自己的工程 2. 关联使用 ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) implementation project(":popuplistview") ... } ``` 3. gradle sync 方式二: ``` allprojects { repositories { mavenCentral() } } ... dependencies { ... implementation 'com.gitee.archermind-ti:PopupListView:1.0.0-beta' ... } ``` ### 使用说明 要使用 PopupListView,您需要在主布局 xml 中添加以下代码: ``` java ``` 需要您设计一个listView item的布局,然后作为extend view,点击list item后显示 #### 在代码中设置列表 在主布局设置 PopupListView 并设计两个布局后,一个用于列表项,另一个用于内部视图,现在可以在代码中设置并使用它了要设置它: ``` java ArrayList popupViews = new ArrayList<>; //创建列表弹出内容项 for (int i = 0; i < 10; i++) { p = i; PopupView popupView = new PopupView(getContext(), ResourceTable.Layout_popup_view_item) { @Override public void setViewsElements(Component view) { Text textView = (Text) view.findComponentById(ResourceTable.Id_title); textView.setText("Popup View " + String.valueOf(p)); } @Override public Component setExtendView(Component view) { Component extendView; if (view == null) { extendView = LayoutScatter.getInstance(getContext()).parse(ResourceTable .Layout_extend_view, null, false); Text innerText = (Text) extendView.findComponentById(ResourceTable.Id_innerText); innerText.setText("Inner View " + String.valueOf(p)); } else { extendView = view; } return extendView; } }; popupViews.add(popupView); } //创建所有弹出列表项后,将其设置为 PopupListView PopupListView popupListView = (PopupListView) findComponentById(ResourceTable.Id_popupListView); popupListView.init(null,popupViews); //然后你可以使用它了!! ``` #### 配置属性 如果您只是单击该项目并且它已经扩展当您想缩小它时调用以下代码 ``` java if(popupListView.isZoomIn()){ popupListView.zoomOut(); } ``` 如果在用户单击后退按钮时需要缩小,只需在您的Ability中添加以下代码 ``` java @Override public void onBackPressed() { if (popupListView.isItemZoomIn()) { popupListView.zoomOut(); } else { super.onBackPressed(); } } ``` ### 版本迭代 * v1.0.0 License ------------ A subclass of the Ohos ListView component that enables item click to extend. Copyright 2015 CHEN WEI-LUNG 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.