Head Fisrt Android Development读书笔记(7)Multi Screep Apps

本文介绍了Android应用中实现屏幕导航的基本步骤,包括创建新的Activity、使用Intent进行页面跳转等,并详细阐述了如何创建菜单文件及处理菜单项选择的过程。

Screen Navigation

1.Create a new Activity and configure it to use a new Layout

2.Create an Intent

3.Call startActivity or startActvityForResult to launch a new screen

4.onActivityResult to deal with data result from launched activity


New Menu Steps

1.Create a new menu XML file from the new XML file wizard

2.Add menu items

3.Inflate the menu using the MenuInflater in the onCreateOptionsMenu method in your activity /// getMenuInflater();

4.Process the menu action in onMenuItemSelected in your activity.

startActivity & Intent

Android maintains a stack of Activities your app has started, beginning with the first Activity in your app. As you start new Activtities like you did with the time entry screen, it's automatically added to the back of Activities.

Intent is an abstracted description of an operation to be performed. It can be used with startActivtiy to launch an Activity

Intent intent = new Intent(this, AddTimeActivity.class); // from , to

Intent intent = getIntent() calling getIntent() retrieves the starting intent from a running Activity.

intent.putExtra("time", ....)

this.setResult(RESULT_OK, intent);

call finish() to complete a screen and automatically display the previous screen on the back stack

startActivityForResult

EditText

use EditText for text entry

<EditText ... />


Menu

/res/menu for menu layout

activity onCreateOptionsMenu()

public void onCreateOptionsMenu(Menu m) {

super.onCreateOptionsMenu(m);

MenuInflater menuInflater = getMenuInflatter();

menuInflater.inflate(R.menu.time_list_menu, menu);

}

capture the menu action: onMenuItemSelected


Adapter

adapter.notifyDataSetChanged(); this method let list know the data has changed and update the diaplay



评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值