• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

cricklet/Android-PanesLibrary: (deprecated ~2012) Easily create Android apps wit ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

cricklet/Android-PanesLibrary

开源软件地址(OpenSource Url):

https://github.com/cricklet/Android-PanesLibrary

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

Disclaimer: unfortunately, I don't do Android dev anymore, so I can't maintain this library.

Android PanesLibrary

PanesLibrary

This library makes it easy to make native Android apps with multi-pane tablet layouts. On the phone, the app appears as a conventional app with a sliding menu and a content pane where fragments are stacked on top of each other. On the tablet, the menu and all other fragments appear in dynamically added panes of varying sizes.

Example

ExampleActivity demonstrates all the necessary configuration for using PanesActivity.

ExampleFragment uses a layout with two TextViews and a Button. The TextViews hold the index of the fragment and the length of time it's been alive. This is used to demonstrate that fragments are correctly retained on activity restarts. The Button has a callback which creates a new fragment and adds it to the parent activity.

Using PanesLibrary

Make sure you have the most up-to-date support library and ActionBarSherlock.

Have your activity extend PanesActivity. Then, add fragments to the activity using the following functions:

  • setMenuFragment(fragment): set the menu
  • addFragment(prevFragment, newFragment): adds newFragment after the prevFragment (clobbering any fragments that used to be after prevFragment)
  • clearFragments(): removes all the fragments except the menu fragment
  • getMenuFragment(): get the menu fragment
  • getTopFragment(): get the fragment on the top of the stack

You also need to provide a PaneSizer. This object allows you to programatically set the width of each pane based on the type of Fragment/View you want to place inside the pane.

You should also implement updateFragment(...). This is run whenever a fragment is added (even on activity restarts).

Fragments are added onto a stack where the 0th fragment is the menu. Here's an example of what this means:

> setMenuFragment(A)
stack: A

> addFragment(A, B)
stack: A, B

> addFragment (B, C)
stack: A, B, C

> addFragment (C, D)
stack: A, B, C, D

> addFragment(B, E)
stack: A, B, E

>clearFragments()
stack: A

Note: PanesActivity requires you to use fragments. If you don't use fragments, you can still use PanesLayout manually.

PanesLayout (this controls the tablet layout)

The hierarchy of a PanesLayout looks like this:

|--------------------------------|
| PanesLayout                    |
| |----------------------------| |
| | PaneScrollView             | |
| | |------------------------| | |
| | | PaneView |-----------| | | |
| | |          | (content) | | | |
| | |          |-----------| | | |
| | |------------------------| | |
| |----------------------------| |
|--------------------------------|

A PanesLayout can hold any number of panes. Each pane is made up of a PaneScrollView (which allows the pane contents to slide left & right), a PaneView (which provides padding on the left of the content), and some content (i.e. fragment).

Variables associated with each pane:

  • type: the possible values of type are defined by the user. For example, in ExampleActivity, the only possible type is DEFAULT_PANE_TYPE. This variable is used to size the pane by the PaneSizer
  • focused: if true, then PanesLayout will never intercept touch events associated with this pane.
  • index: the index of this pane-- starting at 0, going to # of panes - 1.

To add/remove/get panes:

  • addPane(int type)
  • addPane(int type, boolean focused)
  • removePanes(int i): removes all panes after the ith index
  • getNumPanes(): the number of panes
  • getCurrentIndex(): the current top index
  • setIndex(int index): scroll to the pane associated with index.

Listeners/delegates:

  • PaneSizer: determines what the type/focus of a pane should be based on some associated object (i.e. Fragment or View)
  • OnIndexChangedListener: this is fired whenever the visible panes change.
Copyright 2013 Kenrick Rilee

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人参与评论

请发表评论

全部评论

专题导读
上一篇:
tdlib/td: Cross-platform library for building Telegram clients发布时间:2022-08-15
下一篇:
OSSpk/Library-Management-System-JAVA: 发布时间:2022-08-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap