Head Fisrt Android Development读书笔记(3)When things take time
来源:互联网 发布:英雄杀最新探宝数据 编辑:程序博客网 时间:2024/05/22 04:30
The activity lifecycle
onCreate() : called when your activity is created and typically where layouts and configuration occurs -->
onStart(): called when your activity is displayed on the screen. -->
onResume()\onPause(): this could be caused by a phone call, an alert from another application, or a user switching to a different app.
Auto-refresh mechanism is processor and battery intensive. (How sensitive???)
android:gravity="center"
android:padding="5dp" controls the spaceing between views within a layout
android:layout_marginTop="5dp" controls the spacing between this view and the views outside this layout.
android:backgroud="#FF8D8D8D"
android:layout_height="wrap_content": just as big bas it needs to be
android:layout_hegiht="fill_parent". fill all of the space it can
android:layout_weight="1" make the view stretch, "0" make that view just as big as needed.
ProgressDialog
show a dialog:
ProgressDialog dialog = ProgressDialog.show(this, "Loading", "Loading the image og the Day");
dismiss the dialog
dialog.dismiss();
Dedicated UI thread
Android has a dedicated thread for updating the UI, it it responsible for prepaints, layouts, and other graphical processing that helps keep the UI responsive and keeps animation smooth. The UI has a queue of work, and it continually gets the most important chunk of work to process.
1.KEEP the UI thread FREE of expensive processing for a responsive UI.
2.Make SURE all necessary UI code occurs on the UI thread.
Handler
handler works by keeping a reference to the thread it was created by. You can pass it work and Handler ensures that the code is executed on the insatntiated thread.
Handler handler;
public void onCreat(...)
{
...
handler = new Handler();
refreshFromFeed();
}
pass work to the Handler using post
handler.post(Runnable runnable)
WallpaperManager
WallpaperManager wallpaperManager = WallpaperManager.getInstance(NasaDailyImage.this);
wallpaperManager.setBitmap(image);
Toast
Toast.makeText(NasaDailyImage.this, "Wallpaper set", Toast.LENGTH_SHORT).show();
- Head Fisrt Android Development读书笔记(3)When things take time
- Head Fisrt Android Development读书笔记(1)Adding Behavior
- Head Fisrt Android Development读书笔记(2)Working with Feeds
- Head Fisrt Android Development读书笔记(4)Multiple Device Support
- Head Fisrt Android Development读书笔记(6)Lists and Adapters
- Head Fisrt Android Development读书笔记(7)Multi Screep Apps
- Head Fisrt Android Development读书笔记(7)Database Persistent
- Head First Android Development-笔记
- Android Journey: <<Head First Android Development>>
- 4 Things I Wish I Would Have Known When I Started My Software Development Career
- 4 Things I Wish I Would Have Known When I Started My Software Development Career
- Android C native development – take full control!
- 怎样开发linux内核(HOWTO do Linux kernel development - take 3 (中文版))
- fisrt
- HOWTO do Linux kernel development - take 3 (中文版) (ZT)
- HOWTO do Linux kernel development - take 3 (中文版)
- HOWTO do Linux kernel development - take 3 (中文版)
- HOWTO do Linux kernel development - take 3 (中文版)
- 判断Android手机是否联网
- IE6下 li 错位问题
- 山区行
- PHP 执行系统外部命令 system() exec() passthru()
- 企业级系统架构详解:经典的分层架构
- Head Fisrt Android Development读书笔记(3)When things take time
- flex 的mx:DataGrid 的itemDoubleClick 和 DoubleClick
- Hadoop 异常处理
- 在main函数执行之前和执行之后执行的方法
- 未能恢复-无效的自变量“的解决方法 (GUID分区)LION
- Python中的图
- Struts2 <s:iterator> 标签实现 for 循环式 循环控制
- 又见一帘幽梦
- mysql时间处理函数