首页 文章 精选 留言 我的

精选列表

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

android:eclipse:no proposals没有辅助功能

在mac上刚装完eclipse后,经常使用的eclipse辅助输入的快捷键竟然没有建议,纠结n久,最终还是在stackoverflow找到问题 Tryrestoring the default optionsin 'Windows > Preferences > Java > Editor > Content Assist > Advanced' (example of the kind of data you see in this preference screen, not necessarily what you have though) http://stackoverflow.com/questions/908489/eclipse-java-code-completion-not-working 本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/05/21/2512172.html,如需转载请自行联系原作者

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

Android获取View对应的Bitmap

我的应用里面有一个需求,将一个画面分享出去,这个画面底层是一个View,所以首先要把这个View转换成Bitmap,然后在分享这个bitmap即可。话不多说,直接上代码。 有个地方需要注意一下:就是//Draw background的代码不能省略,否则生成的图片背景就是黑色的了。 == public static Bitmap getBitmapFromView(View v) { Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.RGB_565); Canvas c = new Canvas(b); v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); // Draw background Drawable bgDrawable = v.getBackground(); if (bgDrawable != null) bgDrawable.draw(c); else c.drawColor(Color.WHITE); // Draw view to canvas v.draw(c); return b; } == 本文转自zdd博客园博客,原文链接:http://www.cnblogs.com/graphics/p/5933773.html,如需转载请自行联系原作者

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

Android -- Activity的销毁和重建

两种销毁 第一种是正常的销毁,比如用户按下Back按钮或者是activity自己调用了finish()方法; 另一种是由于activity处于stopped状态,并且它长期未被使用,或者前台的activity需要更多的资源,这些情况下系统就会关闭后台的进程,以恢复一些内存。 需要注意的是这其中有一种情况就是屏幕旋转的问题,当用户旋转手机屏幕,每一次都会导致activity的销毁和重新建立。 在第二种情况下,尽管实际的activity实例已经被销毁,但是系统仍然记得它的存在,当用户返回到它的时候,系统会创建出一个新的实例来代替它,这里需要利用旧实例被销毁时候存下来的数据。这些数据被称为“instance state”,是一个存在Bundle对象中的键值对集合。 缺省状态下,系统会把每一个View对象保存起来(比如EditText对象中的文本,ListView中的滚动条位置等),即如果activity实例被销毁和重建,那么不需要你编码,layout状态会恢复到前次状态。 但是如果你的activity需要恢复更多的信息,比如成员变量信息,则需要自己动手写了。 onSaveInstanceState() 如果要存储额外的数据,必须覆写回调函数onSaveInstanceState(). 系统会在用户离开activity的时候调用这个函数,并且传递给它一个Bundle object,如果系统稍后需要重建这个activity实例,它会传递同一个Bundle object到onRestoreInstanceState()和onCreate()方法中去。 当系统停止activity时,它会调用onSaveInstanceState()(过程1),如果activity被销毁了,但是需要创建同样的实例,系统会把过程1中的状态数据传给onCreate()和onRestoreInstanceState()(图中标出的2和3)。 存储Activity状态 当系统停止activity时,系统会调用onSaveInstanceState(),状态信息会以键值对的形式存储下来。 默认的实现中存储了activity的view系列的状态,比如文本和滚动条位置等。 要存储额外的信息,必须自己实现onSaveInstanceState(),并且给Bundle object加上键值对。 static final String STATE_SCORE = "playerScore"; static final String STATE_LEVEL = "playerLevel"; ... @Override public void onSaveInstanceState(Bundle savedInstanceState) { // Save the user's current game state savedInstanceState.putInt(STATE_SCORE, mCurrentScore); savedInstanceState.putInt(STATE_LEVEL, mCurrentLevel); // Always call the superclass so it can save the view hierarchy state super.onSaveInstanceState(savedInstanceState); } 要记得调用基类的实现,以实现默认的实现。 恢复Activity状态 当activity重建时,需要根据Bundle中的状态信息数据恢复activity。onCreate() 和onRestoreInstanceState()回调函数都会接收到这个Bundle。 因为每次创建新的activity实例的或重建一个实例的时候都会调用onCreate()方法,所以必须先检查是否Bundle是null,如果是null,则表明是要创建一个全新的对象,而不是重建一个上次被销毁的对象。 比如onCreate()方法可以这么写: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Always call the superclass first // Check whether we're recreating a previously destroyed instance if (savedInstanceState != null) { // Restore value of members from saved state mCurrentScore = savedInstanceState.getInt(STATE_SCORE); mCurrentLevel = savedInstanceState.getInt(STATE_LEVEL); } else { // Probably initialize members with default values for a new instance } ... } 除了在onCreate()中恢复状态外,也可以选择在onRestoreInstanceState()中实现,这个函数在onStart()之后调用。 只有在有数据要恢复的时候系统会调用onRestoreInstanceState(),所以不必检查Bundle是否为null。 public void onRestoreInstanceState(Bundle savedInstanceState) { // Always call the superclass so it can restore the view hierarchy super.onRestoreInstanceState(savedInstanceState); // Restore state members from saved instance mCurrentScore = savedInstanceState.getInt(STATE_SCORE); mCurrentLevel = savedInstanceState.getInt(STATE_LEVEL); } 此处也要注意,不要忘记调用基类实现。 我是天王盖地虎的分割线 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/3920969.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应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

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