Android双列滑动表格(双表头不动)
※效果
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGluZ2xvbmd4aW4yNA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
※使用方法
package com.cd.slidetest; import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView; public class MainActivity extends Activity implements OnScrollChangedListener{ private GestureDetector mGestureDetector = null;
private HScrollView mItemRoom = null;
private ScrollView mVertical = null;
private HScrollView mTimeItem = null;
private LinearLayout mContain = null;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGestureDetector = new GestureDetector(mGestureListener);
makeItems();
setContentView(mContain); } @Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
} private void makeItems(){
mItemRoom = new HScrollView(this, mGestureDetector);
mItemRoom.setListener(this);
LinearLayout VLayout = new LinearLayout(this);
VLayout.setOrientation(LinearLayout.VERTICAL); for(int i = 0;i < 20;i++){
LinearLayout HLayout = new LinearLayout(this);
for(int j = 0;j < 10;j++){
TextItem item = new TextItem(this);
item.setText(i*10+j + "vh");
item.setBackgroundColor(Color.LTGRAY);
LinearLayout.LayoutParams params = new LayoutParams(100,70);
HLayout.addView(item, params);
}
VLayout.addView(HLayout);
} mItemRoom.addView(VLayout); mVertical = new ScrollView(this);
LinearLayout hlayout = new LinearLayout(this);
LinearLayout vlayout = new LinearLayout(this);
vlayout.setOrientation(LinearLayout.VERTICAL);
for(int i = 0;i < 20;i++){
TextItem item = new TextItem(this);
item.setBackgroundColor(Color.BLUE);
item.setText(i + "v");
LinearLayout.LayoutParams params = new LayoutParams(100,70);
vlayout.addView(item, params);
}
hlayout.addView(vlayout);
hlayout.addView(mItemRoom); mVertical.addView(hlayout); LinearLayout tophlayout = new LinearLayout(this);
mTimeItem = new HScrollView(this, mGestureDetector);
mTimeItem.setListener(this);
LinearLayout layout = new LinearLayout(this);
for(int i = 0;i < 10;i++){
TextItem item = new TextItem(this);
item.setText(i + "h");
item.setBackgroundColor(Color.GREEN);
LinearLayout.LayoutParams params = new LayoutParams(100,70);
layout.addView(item,params);
}
mTimeItem.addView(layout);
TextItem item = new TextItem(this);
item.setBackgroundColor(Color.RED);
LinearLayout.LayoutParams params = new LayoutParams(100,70);
tophlayout.addView(item,params);
tophlayout.addView(mTimeItem); mContain = new LinearLayout(this);
mContain.setOrientation(LinearLayout.VERTICAL);
mContain.addView(tophlayout);
mContain.addView(mVertical);
} private SimpleOnGestureListener mGestureListener = new SimpleOnGestureListener(){ @Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
if(Math.abs(distanceX) > Math.abs(distanceY)) {
return true;
}
return false;
} };
@Override
public void onScrollChanged(HScrollView scroll, int x, int y, int oldx,
int oldy) {
if(scroll == mItemRoom){
mTimeItem.scrollTo(x, y);
}else if(scroll == mTimeItem){
mItemRoom.scrollTo(x, y);
} }
}
※下载地址
http://download.csdn.net/detail/u010785585/8062787
Android双列滑动表格(双表头不动)的更多相关文章
- JAVA双列集合HashMap
HashMap 双列集合HashMap是属于java集合框架3大类接口的Map类, Map接口储存一组成对的键-值对象,提供key(键)到value(值)的映射.Map中的key不要求有序,不允许 ...
- Android 摇一摇之双甩功能
Android 摇一摇之双甩功能 最近做一个摇一摇的功能 网上相关代码很多 但是这次的需求有点奇葩 要求是摇两次才生效 看起来好像很简单 但真正要做遇到的问题还是很多 时间限制 机型灵敏性 摇动的方式 ...
- (10)集合之双列集合Map,HashMap,TreeMap
Map中的元素是两个对象,一个对象作为键,一个对象作为值.键不可以重复,但是值可以重复. 看顶层共性方法找子类特有对象. Map与Collection在集合框架中属并列存在 Map存储的是键值对 Ma ...
- 双列集合Map
1.双列集合Map,就是存储key-value的键值对. 2.hashMap中键必须唯一,值可以不唯一. 3.主要方法:put添加数据 getKey---通过key获取数据 keySet- ...
- Map集合——双列集合
双列集合<k, v> Map: Map 和 HashMap是无序的: LinkedHashMap是有序的: HashMap & LinkedHashMap: put方法: 其中,可 ...
- C#之单列双列集合绑定数据
---恢复内容开始--- 1.单列集合绑定方式 davList.DataSource=new BindingList<类型名>(集合名); 2.双列集合绑定方式 BindingSource ...
- 双列集合Map的嵌套遍历
双列集合Map的嵌套使用,例如HashMap中还有一个HashMap,这样的集合遍历起来稍微有点儿复杂.例如一个集合:HashMap<Integer,HashMap<String,Inte ...
- java oop 单列 双列 集合, 迭代器 的使用和说明
一.集合(Collection) (1)集合的由来? 我们学习的是Java -- 面向对象 -- 操作很多对象 -- 存储 -- 容器(数组和StringBuffer) -- 数组 而数组的长度固定, ...
- Properties -IO相关的双列集合类
IO相关的集合类 java.util.Properties集合 extends hashtable(淘汰) Properties类表示了一个持久的属性集.Properties可保存流中或从流中加载 P ...
随机推荐
- core 中使用 swagger
引包 代码 public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc().Set ...
- core下的routelink
core mvc中 routelink返回和 framework mvc中返回的不一样,core中返回 IHtmlContent, 而 fw 中返回 MvcHtmlString 在写分页方法中用到了r ...
- 输入防抖 vue # 输入搜索的时候 及时搜索的快速访问接口的 解决方案 vue 中使用防抖和节流
输入防抖 watch: { value (newVal, oldVal) { if (this.timer) { clearTimeout(this.timer) } this.timer = set ...
- faster rcnn环境编译
步骤和fast rcnn的编译一样,在编译中遇到了一个问题: 刚开始是以为python-numpy没有安装到位,后来发现是Makefile.config的配置出现了问题.原来的配置是: PYTHON_ ...
- 通俗理解 模糊自适应PID
模糊自适应PID算法就是在经典的PID的基础上添加模糊控制规则库,建立这个库的目的就是算法能够自己来进行改变P.I.D的值. 就拿温度的上升过程控制来说,刚开始的时候,希望温度能够快速的升到终点温度, ...
- Microsoft Windows Server 系统基本配置
Microsoft Windows Server 系统基本配置 环境基本配置 桌面和显示属性 更新服务器名称 更新用户密码 创建密码重置盘 设置网络类型 TCP/IP设置 ping和ipconfig命 ...
- PHP13 会话控制
学习要点 会话控制使用的意义 用户跟踪方式 Cookie的设置.读取以及删除 Session的设置.读取以及删除 自定义session处理方式 会话控制 什么是会话控制 实现服务器跟踪同一个客户端的连 ...
- OpenCV2:第七章 图像处理
一.简介 灰度图(灰阶图),把白色到黑色之间分为256阶灰度 彩色图有RGB三个分量,假设图是800*800像素,那么就有三个800*800的矩阵分别代表RGB 二值化处理设定阈值,在阈值中的像素值变 ...
- openmediavault 4.1.3 插件开发
参考网址:https://forum.openmediavault.... 创建应用GUI 创建应用目录:/var/www/openmediavault/js/omv/module/admin/ser ...
- LeetCode(25)Reverse Nodes in k-Group
题目 Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. ...