- 浏览: 426898 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
yehuiyan8002:
支持中文查询
快熟查找联系人 -
lehehe:
现成的接口,免费试用,http://www.haoservic ...
天气Widget -
D.Z:
android:focusable="false&q ...
CheckBox在ListView 而导致其OnItemClickListener不会被触发 -
freecode:
碰到该问题,CheckBox的android:focusabl ...
CheckBox在ListView 而导致其OnItemClickListener不会被触发 -
echohfut:
哥们,新博客是不是在墙外啊?不能访问。还有你怎么进行博客迁移的 ...
博客 迁移
TabActivity - 自定义
其实 这篇感觉极鸡肋 但是 TabActivity 在标签页太多情况下 会导致界面比较难看 所以今天尝试自己扩展一下
[原理]
用2 LinearLayout 完成之 一个用于存放Image 另一用于显示具体布局
可能有人会说 干嘛不用Gallery组件 显示Image 这是因为Gallery显示特性比较固定 只能水平显示 或者是我不知道 有知道的 望告知
[代码 步骤]
1. 定义布局:main.xml 其中 shortcut显示图片索引 info显示选择id content显示布局内容
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="vertical" android:layout_width="50dip" android:layout_height="wrap_content" android:background="@drawable/dot" android:id="@+id/shortcut" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/info" /> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="10dip" android:id="@+id/content" > </LinearLayout> </LinearLayout>
2. 定义List 用于存放各个标签布局
List<View> viewList;
3. View初始化
public void init(){ shortcutLinear = (LinearLayout)findViewById(R.id.shortcut); contentLinearLayout = (LinearLayout)findViewById(R.id.content); infoText = (TextView)findViewById(R.id.info); viewList = new ArrayList<View>(); inflatorHelper = this.getLayoutInflater(); }
4. 定义addTab() 用于接受图标索引 布局文件
public void addTab(int id,Drawable drawable,View view){ //1. to add ImageView into shortcut LinearLayout ImageView iv = new ImageView(this); iv.setImageDrawable(drawable); shortcutLinear.addView(iv, id); //2. to add View into List<View> viewList.add(id,view); } public void addTab(Drawable drawable,View view){ //1. to add ImageView into shortcut LinearLayout ImageView iv = new ImageView(this); iv.setImageDrawable(drawable); shortcutLinear.addView(iv); //2. to add View into List<View> viewList.add(view); }
5. 如何添加标签页
public void addExampleView(){ ImageView image = new ImageView(this); image.setImageResource(R.drawable.robot); addTab(this.getResources().getDrawable(R.drawable.icon),image); EditText edit = new EditText(this); edit.setWidth(100); addTab(1,this.getResources().getDrawable(R.drawable.hat),edit); TextView text = new TextView(this); text.setText("Hello ~ Text!"); addTab(this.getResources().getDrawable(R.drawable.wyj),text); View panel1 = inflatorHelper.inflate(R.layout.panel1, null); addTab(1,getResources().getDrawable(R.drawable.robot),panel1); }
6. 定义addClickListener() 用于注册LinearLasyout 所有ImageView
public void addClickListener(){ clickListener = new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub int id = v.getId(); infoText.setText(" id:"+id); //to remove all ori View, and then add new View contentLinearLayout.removeAllViews(); if(id < viewList.size()){ contentLinearLayout.addView(viewList.get(id)); } } }; for(int i=1;i<shortcutLinear.getChildCount();i++){ ImageView iv = (ImageView)shortcutLinear.getChildAt(i); iv.setId(i); iv.setOnClickListener(clickListener); } }
7. panel1.xml 布局如下:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="name:" /> <EditText android:layout_width="200dip" android:layout_height="wrap_content" /> <Button android:layout_width="100dip" android:layout_height="wrap_content" android:text="OK" /> </LinearLayout>
8. emulator 运行截图:
- IndexPanelTest.rar (44.6 KB)
- 下载次数: 148
发表评论
-
滑动抽屉 另一种解决办法
2010-07-09 17:43 0滑动抽屉 -
Spinner 定制化 增强版
2010-07-09 14:34 2571Spinner 作为下拉选 ... -
ListView 内容之分批显示
2010-06-25 20:38 5861ListView 内容循环显示 大家试想 假如 ... -
MediaScanner 研究
2010-06-23 15:21 3104MediaScanner 之所以拿MediaSc ... -
CheckBox在ListView 而导致其OnItemClickListener不会被触发
2010-06-22 20:55 18878CheckBox在ListView 而导致其OnItemCli ... -
获取Launcher 启动列表
2010-06-22 10:09 3097获取Launcher 启动列表 即 列出所有Launc ... -
PreferenceActivity 全接触
2010-06-19 12:53 9389PreferenceActivity 为了引入 ... -
android src 下载 编译 安装 全接触
2010-06-12 14:44 0android src - download install ... -
Intent.createChooser() 妙用
2010-06-12 11:14 5917Intent.createChooser(ntent targ ... -
SMS管理:收信箱 发信息 编写新信息
2010-06-07 08:14 14364SMS管理 [功能] 1. 收信箱:显示 ... -
求 android 手机 帮忙测试sms服务系统 谢谢
2010-06-05 08:25 1409Hi guys, 最近一段时间没有更新blog 因为一 ... -
流媒体 播放 理论篇
2010-05-28 14:42 2122流媒体播放 之所以为理论篇 因为该篇仅实现了播放功能 ... -
NDK 搭建与HelloWorld
2010-05-19 09:48 3152NDK [前提] 1. Cygwin 用于安装 ... -
自定义字体
2010-05-15 10:49 1162自定义字体: []代码 步骤] 1 ... -
模糊查找 再深入
2010-05-15 09:41 3096模糊查找 再深入 应某位大哥要求 再次对 SQLite ... -
View 拖动&插入 研究
2010-05-09 07:14 3928View 拖动&插入 即: ... -
带图标 快捷键 Menu - 终极版
2010-05-04 20:23 1784Menu 改头换面 扩展如下: 1. 图标化文字 2 ... -
*.gif 解码 - 实践
2010-05-02 18:58 1650*.gif decode 前面已经说过 今天不打算再说了 ... -
*.gif 解码 - 理论
2010-05-01 21:11 1484我们知道Android 默认是不支持*.gif 的 但是 ... -
shortcut+livefolder
2010-04-19 13:08 1456shortcut+livefolder Live ...
相关推荐
自定义ViewGroup---子View可对换位置
原文地址http://blog.csdn.net/android_cmos/article/details/52356229
自定义ViewGroup(高度不同的列表) MIT License Copyright (c) 2017 JiaoZhengXiang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated ...
自定义ViewGroup+Adapter
MarqueeView:新的里程表式垂直跑马灯,基于viewgroup的自定义控件
继承viewgroup, 编写自定义坐标布局,添加增删时动画操作, 拖动移除效果
最近对自定义控件充满了兴趣,参考网上的视频写了一个流式布局的例子上传到这,和大家交流学习
最近有些空闲时间,我有回顾了一下自定义控件的一些东西,我自定义了一个ViewPager,性能不太好,所以上传到这和大家交流学习
自定义ViewGroup学习 最简单的模式,显示一个TextView到自定义ViewGroup中
自定义VIewGroup组合控件,包括事件的处理,可以运行,值得学习
自定义Viewgroup,其中包括三个listview,但拖拽中间listview的上部,3个listview一起运动。
ViewGroup存在的目的就是为了对其子View进行管理,为其子View...因此,自定义ViewGroup通常需要重写onMeasure()方法来对子View进行测量,重写onLayout()方法来确定子View的位置,重写onTouchEvent()方法增加响应事件。
详细讲解自定义ViewGroup+Scroller+VelocityTracker做出Launcher滑动
安卓自定义ViewGroup 自定义TextView fragment自由切换带渐变 写的demo 好多东西可以用到各种项目里 还有我写的布局 全部相对布局,完美适配各种屏幕,适合新手学习,
自定义Viewgroup 继承了FrameLayout 实现了下拉刷新,效果不错呦
自定义ViewGroup进一步学习,显示两个TextView到自定义控件中,对两个TextView进行布局
自UI工作原理:Viewgroup/View/Window/WindowManager之间关系 Android事件分发机制 View重要属性和方法 自定义控件实现
模仿ViewPager的效果,自定义继承Linerlayout,学习的例子。
自定义ViewGroup实现的圆形旋转菜单,支持跟随手指旋转以及快速旋转。,很值得学习的一个 demo