## 可扩展的选择器 ##
使用:
main.xml 布局
<code>
<!-- 文字按钮 -->
<com.bob.component.ExpandableSelector
android:id="@+id/es_sizes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_margin="@dimen/expandable_selector_margin"/>
<!-- 图片按钮 -->
<com.bob.component.ExpandableSelector
android:id="@+id/es_icons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="@dimen/expandable_selector_margin"
android:background="@drawable/bg_expandable_selector_dark"
expandable_selector:animation_duration="@integer/custom_animation_duration"/>
<!-- 自定义按钮样式 -->
<com.bob.component.ExpandableSelector
android:id="@+id/es_colors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/expandable_selector_margin"
android:background="@drawable/bg_expandable_selector"
expandable_selector:hide_background_if_collapsed="true"
expandable_selector:hide_first_item_on_collapse="true">
<Button
android:id="@+id/bt_colors"
android:text="@string/colors_expandable_selector_title"
style="@style/ExpandableItemStyleHeader"/>
</com.bob.component.ExpandableSelector>
</code>
MainAcitivity.java
<code>
/*
* Copyright (C) 2015 Karumi.
*
* 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.
*/
package com.bob.expandableselector;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Toast;
import com.bob.component.ExpandableItem;
import com.bob.component.ExpandableSelector;
import com.bob.component.ExpandableSelectorListener;
import com.bob.component.OnExpandableItemClickListener;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends ActionBarActivity {
private View colorsHeaderButton;
private ExpandableSelector colorsExpandableSelector;
private ExpandableSelector sizesExpandableSelector;
private ExpandableSelector iconsExpandableSelector;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
initializeColorsExpandableSelector();
initializeSizesExpandableSelector();
initializeIconsExpandableSelector();
initializeCloseAllButton();
}
//初始化自定义样式按钮
private void initializeColorsExpandableSelector() {
colorsExpandableSelector = (ExpandableSelector) findViewById(R.id.es_colors);
List<ExpandableItem> expandableItems = new ArrayList<ExpandableItem>();
expandableItems.add(new ExpandableItem(R.drawable.item_brown));
expandableItems.add(new ExpandableItem(R.drawable.item_green));
expandableItems.add(new ExpandableItem(R.drawable.item_orange));
expandableItems.add(new ExpandableItem(R.drawable.item_pink));
colorsExpandableSelector.showExpandableItems(expandableItems);
colorsHeaderButton = findViewById(R.id.bt_colors);
colorsHeaderButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
colorsHeaderButton.setVisibility(View.INVISIBLE);
colorsExpandableSelector.expand();
}
});
colorsExpandableSelector.setOnExpandableItemClickListener(new OnExpandableItemClickListener() {
@Override public void onExpandableItemClickListener(int index, View view) {
switch (index) {
case 0:
colorsHeaderButton.setBackgroundResource(R.drawable.item_brown);
break;
case 1:
colorsHeaderButton.setBackgroundResource(R.drawable.item_green);
break;
case 2:
colorsHeaderButton.setBackgroundResource(R.drawable.item_orange);
break;
default:
colorsHeaderButton.setBackgroundResource(R.drawable.item_pink);
}
colorsExpandableSelector.collapse();
}
});
}
//文字按钮
private void initializeSizesExpandableSelector() {
sizesExpandableSelector = (ExpandableSelector) findViewById(R.id.es_sizes);
List<ExpandableItem> expandableItems = new ArrayList<ExpandableItem>();
expandableItems.add(new ExpandableItem("XL"));
expandableItems.add(new ExpandableItem("L"));
expandableItems.add(new ExpandableItem("M"));
expandableItems.add(new ExpandableItem("S"));
sizesExpandableSelector.showExpandableItems(expandableItems);
sizesExpandableSelector.setOnExpandableItemClickListener(new OnExpandableItemClickListener() {
@Override public void onExpandableItemClickListener(int index, View view) {
switch (index) {
case 1:
ExpandableItem firstItem = sizesExpandableSelector.getExpandableItem(1);
swipeFirstItem(1, firstItem);
break;
case 2:
ExpandableItem secondItem = sizesExpandableSelector.getExpandableItem(2);
swipeFirstItem(2, secondItem);
break;
case 3:
ExpandableItem fourthItem = sizesExpandableSelector.getExpandableItem(3);
swipeFirstItem(3, fourthItem);
break;
default:
}
sizesExpandableSelector.collapse();
}
private void swipeFirstItem(int position, ExpandableItem clickedItem) {
ExpandableItem firstItem = sizesExpandableSelector.getExpandableItem(0);
sizesExpandableSelector.updateExpandableItem(0, clickedItem);
sizesExpandableSelector.updateExpandableItem(position, firstItem);
}
});
}
//初始化图片按钮
private void initializeIconsExpandableSelector() {
iconsExpandableSelector = (ExpandableSelector) findViewById(R.id.es_icons);
List<ExpandableItem> expandableItems = new ArrayList<ExpandableItem>();
ExpandableItem item = new ExpandableItem();
item.setResourceId(R.drawable.ic_keyboard_arrow_up_black);
expandableItems.add(item);
item = new ExpandableItem();
item.setResourceId(R.drawable.ic_gamepad_black);
expandableItems.add(item);
item = new ExpandableItem();
item.setResourceId(R.drawable.ic_device_hub_black);
expandableItems.add(item);
iconsExpandableSelector.showExpandableItems(expandableItems);
iconsExpandableSelector.setOnExpandableItemClickListener(new OnExpandableItemClickListener() {
@Override public void onExpandableItemClickListener(int index, View view) {
if (index == 0 && iconsExpandableSelector.isExpanded()) {
iconsExpandableSelector.collapse();
updateIconsFirstButtonResource(R.drawable.ic_keyboard_arrow_up_black);
}
switch (index) {
case 1:
showToast("Gamepad icon button clicked.");
break;
case 2:
showToast("Hub icon button clicked.");
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
linux常用命令大全 1.Linux管理文件和目录的命令 命令 功能 命令 功能 Pwd 显示当前目录 ls 查看目录下的内容 Cd 改变所在目录 cat 显示文件的内容 Grep 在文件中查找某字符 cp 复制文件 Touch 创建文件 mv 移动文件 Rm 删除文件 rmdir 删除目录 Vi 编辑文件 1.1 pwd命令 该命令的英文解释为print working directory(打印工作目录)。输入pwd命令,Linux会输出当前目录。 1.2 cd命令 用来改变所在目录。 cd / 转到根目录中 cd ~ 转到/home/user用户目录下 cd /usr 转到根目录下的usr目录中-------------绝对路径 cd test 转到当前目录下的test子目录中-------相对路径 1.3 ls命令 用来查看目录的内容。 选项 含义 -a 列举目录中的全部文件,包括隐藏文件 -l 列举目录中的细节,包括权限、所有者、组群、大小、创建日期、文件是否是链接等 -f 列举的文件显示文件类型 -r 逆向,从后向前地列举目录中内容
资源推荐
资源详情
资源评论
收起资源包目录
Android UI 大全 里面包含所以特效大全的项目,都是每个特效一个项目的结构.zip (1691个子文件)
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
gradlew.bat 2KB
Thumbs.db 36KB
demo2.gif 2.18MB
dialogplusanim.gif 2.08MB
shili.gif 1.59MB
search.gif 1.37MB
Version20效果和Android5.0.gif 1.3MB
dialogplus.gif 1.08MB
LodingDialog.gif 1015KB
特效图.gif 838KB
shili.gif 802KB
dragtop_1.1.0.gif 557KB
Version19.1效果.gif 513KB
dilog.gif 448KB
demo1.gif 242KB
sample4.gif 237KB
sample3.gif 233KB
sample2.gif 217KB
shili.gif 172KB
sample1.gif 160KB
sample5.gif 157KB
cross.gif 93KB
bezier.gif 86KB
tit_bg.gif 215B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 81B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
共 1691 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
野生的狒狒
- 粉丝: 2340
- 资源: 2099
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功