首页 文章 精选 留言 我的

精选列表

搜索[android studio],共10000篇文章
优秀的个人博客,低调大师

android adb端口被占用解决方法

1.输入adb devices命令 C:\Users\Nick>adb devices List of devices attached adb server version (31) doesn't match this client (39); killing... error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 (10048) 可以看出5037端口被占用了 2. 查看端口被哪个暂用 C:\Users\Nick>netstat -ano | findstr "5037" TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 17276 TCP 127.0.0.1:5037 127.0.0.1:61023 TIME_WAIT 0 TCP 127.0.0.1:5037 127.0.0.1:61028 TIME_WAIT 0 TCP 127.0.0.1:5037 127.0.0.1:61033 TIME_WAIT 0 TCP 127.0.0.1:5037 127.0.0.1:61038 TIME_WAIT 0 在任务管理器中查看17276的端口被那个进程暂用。结束进程。 本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/p/7063268.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android RecyclerView 动画展开item显示详情

stackoverflow上看到这个问题,答主给了个demohttp://stackoverflow.com/questions/27446051/recyclerview-animate-item-resize 看懂了之后发个博,记录一下,刚开始看别人代码好难受,就这么3个文件看了一晚上。。 效果如下 res文件 main_activity文件就是一个recyclerview main_item是两个textview 一个标题一个详细信息 MainActivity就是加载了一个RecyclerView public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); final RecyclerView rv = (RecyclerView) findViewById(R.id.rv); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); rv.setLayoutManager(layoutManager); final MainAdapter adapter = new MainAdapter(); rv.setAdapter(adapter); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 MainAdapter中new了一个keepOne对象,点进去看这个类,有两个方法:bind和toggle,其中的bind是在MainAdapter中的onBindViewHolder()方法中调用,而toggle是响应viewholder的点击事件 public static class KeepOneH<VH extends RecyclerView.ViewHolder & Expandable> { // opened为-1表示所有item是关闭状态,open为pos值的表示pos位置的item为展开的状态 private int _opened = -1; public void bind(VH holder, int pos) { if (pos == _opened) // 3 // 直接显示expandView 无动画 ExpandableViewHoldersUtil.openH(holder, holder.getExpandView(), false); else // 直接关闭expandView 无动画 ExpandableViewHoldersUtil.closeH(holder, holder.getExpandView(), false); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 @SuppressWarnings("unchecked") // 响应点击事件的方法 public void toggle(VH holder) { // 如果点击的就是开着的item,就关闭该item并把opened置-1 // ???TODO if (_opened == holder.getPosition()) { _opened = -1; // 关闭expandView 有动画 ExpandableViewHoldersUtil.closeH(holder, holder.getExpandView(), true); } // 如果点击其他本来关闭着的item,则把opened值换成当前pos,把之前开的item给关掉 else { int previous = _opened; _opened = holder.getPosition(); // 展开expandView 有动画 ExpandableViewHoldersUtil.openH(holder, holder.getExpandView(), true); // 用动画关闭之前的item final VH oldHolder = (VH) ((RecyclerView) holder.itemView.getParent()).findViewHolderForPosition(previous); if (oldHolder != null) ExpandableViewHoldersUtil.closeH(oldHolder, oldHolder.getExpandView(), true); } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 点进openH和closeH方法进去看 // 4 public static void openH(final RecyclerView.ViewHolder holder, final View expandView, final boolean animate) { // animate参数为true,则有动画效果 if (animate) { expandView.setVisibility(View.VISIBLE); // 5 // 改变高度的动画,具体操作点进去看 final Animator animator = ViewHolderAnimator.ofItemViewHeight(holder); // 扩展的动画结束后透明度动画开始 animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(expandView, View.ALPHA, 1); alphaAnimator.addListener(new ViewHolderAnimator.ViewHolderAnimatorListener(holder)); alphaAnimator.start(); } }); animator.start(); } // animate参数为false,则直接设置为可见 else { expandView.setVisibility(View.VISIBLE); expandView.setAlpha(1); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 openH方法接收3个参数, 第一个是viewholder. 第二个是展开部分的view,由holder.getExpandView()方法获取。这里定义了一个接口 public static interface Expandable { public View getExpandView(); } 1 2 3 1 2 3 在MainAdapter中传入infos这个Textview @Override public View getExpandView() { return infos; } 1 2 3 4 1 2 3 4 第三个是一个标记,true时有动画,false时直接设置其展开或者是关闭的状态。所以在bind()方法中调用的openH()都是false,而toggle()中调用的设置为true。 openH方法中 具体动画的操作为ViewHolderAnimator.ofItemViewHeight(holder) public static Animator ofItemViewHeight(RecyclerView.ViewHolder holder) { View parent = (View) holder.itemView.getParent(); if (parent == null) throw new IllegalStateException("Cannot animate the layout of a view that has no parent"); // 测量扩展动画的起始高度和结束高度 int start = holder.itemView.getMeasuredHeight(); holder.itemView.measure(View.MeasureSpec.makeMeasureSpec(parent.getMeasuredWidth(), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); int end = holder.itemView.getMeasuredHeight(); // 6 final Animator animator = LayoutAnimator.ofHeight(holder.itemView, start, end); // 设定该item在动画开始结束和取消时能否被recycle animator.addListener(new ViewHolderAnimatorListener(holder)); // 设定结束时这个item的宽高 animator.addListener(new LayoutParamsAnimatorListener(holder.itemView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); return animator; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 可以看出 具体展开的动画在LayoutAnimator.ofHeight(holder.itemView, start, end);中,ViewHolderAnimator只是测量参数,设定监听两个监听事件 1设定在动画开始结束和取消状态下是否可以被回收 public ViewHolderAnimatorListener(RecyclerView.ViewHolder holder) { _holder = holder; } @Override public void onAnimationStart(Animator animation) { _holder.setIsRecyclable(false); } @Override public void onAnimationEnd(Animator animation) { _holder.setIsRecyclable(true); } @Override public void onAnimationCancel(Animator animation) { _holder.setIsRecyclable(true); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2.设定在动画结束后view的高和宽分别为warp_content,match_parent. public static class LayoutParamsAnimatorListener extends AnimatorListenerAdapter { private final View _view; private final int _paramsWidth; private final int _paramsHeight; public LayoutParamsAnimatorListener(View view, int paramsWidth, int paramsHeight) { _view = view; _paramsWidth = paramsWidth; _paramsHeight = paramsHeight; } @Override public void onAnimationEnd(Animator animation) { final ViewGroup.LayoutParams params = _view.getLayoutParams(); params.width = _paramsWidth; params.height = _paramsHeight; _view.setLayoutParams(params); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 再深入一层看展开的动画 public class LayoutAnimator { public static class LayoutHeightUpdateListener implements ValueAnimator.AnimatorUpdateListener { private final View _view; public LayoutHeightUpdateListener(View view) { _view = view; } @Override public void onAnimationUpdate(ValueAnimator animation) { final ViewGroup.LayoutParams lp = _view.getLayoutParams(); lp.height = (int) animation.getAnimatedValue(); _view.setLayoutParams(lp); } } public static Animator ofHeight(View view, int start, int end) { final ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.addUpdateListener(new LayoutHeightUpdateListener(view)); return animator; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 是用ValueAnimator.ofInt生成一系列高度值,然后监听动画的变化,不断设定view的高度值 http://blog.csdn.net/gulumi_mmga/article/details/46683437 本文转自 一点点征服 博客园博客,原文链接:http://www.cnblogs.com/ldq2016/p/5825015.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册
修改密码
忘记密码