今日工作
一、 简单使用Bugzilla
1. 登录账号
2. 使用快速查询,查询一位同事近期处理的bug:assignee:***.*** @unisoc.com
3. 学习新建一个Task类型的Bug的步骤
二、Android学习
1. 在活动中使用Menu
1) 什么是Menu?
2) 怎么实现?
step1:res目录下创建Menu resource file,使用<item…/>
step2:活动中创建菜单(重写onCreateOptionsMenu())
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main,menu); //inflate()方法为当前活动创建菜单
return true; //true表示允许创建的菜单显示出来
}
step3:定义菜单响应事件(重写onOptionsItemSelected())
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.add_item:
Toast.makeText(this,"You clicked Add",Toast.LENGTH_SHORT).show();
break;
case R.id.remove_item:
Toast.makeText(this,"You clicked Remove",Toast.LENGTH_SHORT).show();
break;
default:
}
return true;
}
item.getItemId()判断点击哪个菜单项
2. lntent
1) 作用:各组件间进行交互,活动响应Intent
2) 显式Intent:Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
隐式Intent:
a) 什么活动会响应隐式Intent?
AndroidManifest.xml中活动的<action>、<category>、<data>等标签同时匹配Intent指定的action和category。
每个Intent对象只能指定一个action:Intent intent = new Intent("com.sprd.activitytest.ACTION_START");
但可以指定多个category:intent.addCategory("com.sprd.activitytest.MY_CATEGORY");(已有默认category,再加一个category)
加上data的话:
intent.setData(Uri.parse("http://www.google.com")); //setData()指定当前Intent正在操作的数据
对应活动清单中要有<data android:scheme=”http”>
b) 使用隐式Intent启动其他程序的活动
上网:Intent intent = new Intent(Intent.ACTION_VIEW);
打电话:Intent intent = new Intent(Intent.ACTION_DIAL);
ACTION_VIEW和ACTION_DIAL都是系统内置的常量值。
c) Intent传递数据
传数据给下一个活动:
i. 活动1使用putExtra()将数据暂存在Intent对象中,然后用这个Intent启用活动2
intent.putExtra("extra_data",data); //putExtra()传递数据
ii. 活动2就可以使用getIntent()取出启用自己的Intent
Intent intent = getIntent();
然后用getStringExtra()去除数据值
String data = intent.getStringExtra("extra_data");
传数据给上一个活动:
startActivityForResult()可以启用活动,并在活动销毁时能够返回结果给上一个活动。
活动1中需要onActivityResult()方法,该方法有三个参数:请求码、数据处理结果、携带返回数据的Intent。
明日工作
学习活动的生命周期
今日工作
一、 简单使用Bugzilla
1. 登录账号
2. 使用快速查询,查询一位同事近期处理的bug:assignee:***.*** @unisoc.com
3. 学习新建一个Task类型的Bug的步骤
二、Android学习
1. 在活动中使用Menu
1) 什么是Menu?
2) 怎么实现?
step1:res目录下创建Menu resource file,使用<item…/>
step2:活动中创建菜单(重写onCreateOptionsMenu())
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main,menu); //inflate()方法为当前活动创建菜单
return true; //true表示允许创建的菜单显示出来
}
step3:定义菜单响应事件(重写onOptionsItemSelected())
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.add_item:
Toast.makeText(this,"You clicked Add",Toast.LENGTH_SHORT).show();
break;
case R.id.remove_item:
Toast.makeText(this,"You clicked Remove",Toast.LENGTH_SHORT).show();
break;
default:
}
return true;
}
item.getItemId()判断点击哪个菜单项
2. lntent
1) 作用:各组件间进行交互,活动响应Intent
2) 显式Intent:Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
隐式Intent:
a) 什么活动会响应隐式Intent?
AndroidManifest.xml中活动的<action>、<category>、<data>等标签同时匹配Intent指定的action和category。
每个Intent对象只能指定一个action:Intent intent = new Intent("com.sprd.activitytest.ACTION_START");
但可以指定多个category:intent.addCategory("com.sprd.activitytest.MY_CATEGORY");(已有默认category,再加一个category)
加上data的话:
intent.setData(Uri.parse("http://www.google.com")); //setData()指定当前Intent正在操作的数据
对应活动清单中要有<data android:scheme=”http”>
b) 使用隐式Intent启动其他程序的活动
上网:Intent intent = new Intent(Intent.ACTION_VIEW);
打电话:Intent intent = new Intent(Intent.ACTION_DIAL);
ACTION_VIEW和ACTION_DIAL都是系统内置的常量值。
c) Intent传递数据
传数据给下一个活动:
i. 活动1使用putExtra()将数据暂存在Intent对象中,然后用这个Intent启用活动2
intent.putExtra("extra_data",data); //putExtra()传递数据
ii. 活动2就可以使用getIntent()取出启用自己的Intent
Intent intent = getIntent();
然后用getStringExtra()去除数据值
String data = intent.getStringExtra("extra_data");
传数据给上一个活动:
startActivityForResult()可以启用活动,并在活动销毁时能够返回结果给上一个活动。
活动1中需要onActivityResult()方法,该方法有三个参数:请求码、数据处理结果、携带返回数据的Intent。
明日工作
学习活动的生命周期