android note1
摘要:Note:Your implementation of these lifecycle methods must always call the superclass implementation before doing any work, as shown in the examples above.you can register aBroadcastReceiverinonStart()to monitor changes that impact your UI, and unregister it inonStop()when the user can no longer see w
阅读全文
posted @
2012-02-23 21:09
Lee_Alvin
阅读(132)
推荐(0)
Android UI 相关知识
摘要:android.content.res 资源类 int getColor(int id) 对应res/values/colors.xml Drawable getDrawable(int id) 对应res/drawable/ XmlResourceParser getLayout(int id) 对应res/layout/ String getString(int id) 和CharSequence getText(int id) 对应res/values/strings.xml InputStream openRawResource(int id) 对应res/raw/ ...
阅读全文
posted @
2012-02-21 17:05
Lee_Alvin
阅读(134)
推荐(0)
(转) 宏的副作用
摘要:试题3:写一个“标准”宏MIN,这个宏输入两个参数并返回较小的一个。另外,当你写下面的代码时会发生什么事?least = MIN(*p++, b); 解答:#define MIN(A,B) ((A) <= (B) ? (A) : (B)) MIN(*p++, b)会产生宏的副作用 剖析: 这个面试题主要考查面试者对宏定义的使用,宏定义可以实现类似于函数的功能,但是它终归不是函数,而宏定义中括弧中的“参数”也不是真的参数,在宏展开的时候对“参数”进行的是一对一的替换。 程序员对宏定义的使用要非常小心,特别要注意两个问题: (1)谨慎地将宏定义中的“参数”和整个宏用用括弧括起来。所以,...
阅读全文
posted @
2012-02-20 09:50
Lee_Alvin
阅读(190)
推荐(0)
android琐碎笔记
摘要:1.得到屏幕的screen dimensionsDisplay display = getWindowManager().getDefaultDisplay();int width = display.getWidth();int height = display.getHeight();2. 播放 gif图片在android@Override protected void onDraw(Canvas canvas) {canvas.drawColor(0xFFCCCCCC); Paint p = new Paint(); p.setAntiAlias(true); canvas.drawBi
阅读全文
posted @
2012-02-16 10:53
Lee_Alvin
阅读(275)
推荐(0)
螺旋队列算法分析 (转载)
摘要:(转)http://blog.csdn.net/yhmhappy2006/article/details/2934435螺旋队列的样子如下图:两大规律:1。螺旋规律(红线)2。奇数平方规律(紫线)问题描述:设1的坐标是(0,0),的方向向右为正,y方向向下为正,例如,7的坐标为(-1,-1),2的坐标为(0,1)。编程实现输入任意一点坐标(x,y),输出所对应的数字!问题解决:从紫线突破。从图中不难发现,右上角vc=(2*t+1)(2*t+1),t为该圈x,y坐标的绝对值的最大值。例如vc=9、25、49、81........,算出vc后,就分4个判断区域,分别判断,点落在该圈4条边的哪条边上
阅读全文
posted @
2012-02-15 16:34
Lee_Alvin
阅读(170)
推荐(0)
Android中关于分享的实现
摘要:Android 使用MMS彩信或者Gmail发送图片Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_STREAM,imageUri);//这里必须是图片的uri i.setType("image/jpeg"); startActivity(Intent.createChooser(i,TITLE_TIP));//TITLE_TIP是弹出的选择程序处理的文字标题==================================================Android 使用短信或者Gm
阅读全文
posted @
2012-02-13 16:50
Lee_Alvin
阅读(203)
推荐(0)
Android 错误之 android java.lang.ClassCastException android.app.Application (转载)
摘要:Android 错误之 android java.lang.ClassCastException android.app.Application 定义类 DemoApp , 结果 Activity 调用始终报类错郁闷呀! class DemoApp extends Application{ } 翻看N多页百度无果,哎谷歌偶看老外遇到过硬着头皮看发现android:name=".ApiDemoApp"少指定Application类名。 <application android:icon="@drawable/icon" android:label=&
阅读全文
posted @
2012-02-13 16:12
Lee_Alvin
阅读(982)
推荐(0)
设置Activity的属性
摘要:设置Activity的属性,两种方式:1:在manifest文件中指定的activity增加属性android:theme = "@android:style/Theme.CustomDialog"2:在程序中增加语句setTheme(R.style.Theme_CustomDialog);在onCreate()事件中增加setTheme(),必须在setContentView()之前,否则指定的Style不能生效。http://developer.android.com/guide/topics/resources/available-resources.html#sty
阅读全文
posted @
2012-02-13 15:37
Lee_Alvin
阅读(177)
推荐(0)
android adapter 操作Activity中的方法 ------------弱引用WeakReference----断点记录
摘要:--------------------------背景--------------------------------------------Activity中有个Popupwindow.想在Adapter中的getView中设置Checbox的点击事件时,就显示与隐藏这个Popupwindow但是因为Adapter与Activity不是同一个类,所以操作有点麻烦..--------------------------分割线--------------------------------------------类: Adapter 继承 BaseAdapter类:Activity 继承Act
阅读全文
posted @
2012-02-13 15:13
Lee_Alvin
阅读(1218)
推荐(0)