当前位置: 编程技术>移动开发
本页文章导读:
▪阻截Activity的后退键处理 拦截Activity的后退键处理
以前都是直接Override onKeyDown方法处理的。
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
return true;
}
return super.onKeyDown.........
▪ ExpandableListView / ExpandableListActivity 应用及数据更新 ExpandableListView / ExpandableListActivity 使用及数据更新
ExpandableListView / ExpandableListActivity
二者关系 和 ListActivity / ListView 是一样的
[代码 步骤]
1. 定义含有ExpandableListView 的布局:main.xml.........
▪ menu.addIntentOptions 增添动态菜单 menu.addIntentOptions 添加动态菜单
android的一个activity可以再选中某项之后按menu键弹出特定的菜单,也就是动态菜单。动态菜单的实现是靠menu类中的addIntentOptions函数实现的,具体的声明如下:i.........
[1]阻截Activity的后退键处理
来源: 互联网 发布时间: 2014-02-18
拦截Activity的后退键处理
以前都是直接Override onKeyDown方法处理的。
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
return true;
}
return super.onKeyDown(keyCode, event);
}
今天看了文档发现有个更简单的。Override onBackPressed
@Override
public void onBackPressed() {
if(条件){
return;
}
super.onBackPressed();
}
[2] ExpandableListView / ExpandableListActivity 应用及数据更新
来源: 互联网 发布时间: 2014-02-18
ExpandableListView / ExpandableListActivity 使用及数据更新
ExpandableListView / ExpandableListActivity
二者关系 和 ListActivity / ListView 是一样的
[代码 步骤]
1. 定义含有ExpandableListView 的布局:main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layout"
>
<ExpandableListView
android:id="@+id/expandList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
2. 定义数据结构List<String>, List<List<String>> 分别用于存放 Group / Children 的String
List<String> group;
List<List<String>> child;
3. 初始化 List<String> List<List<String>> 并插入一些数据
public void initialData(){
group = new ArrayList<String>();
child = new ArrayList<List<String>>();
addInfo("griffinshi", new String[]{"13776117119","man","Jiangsu"});
addInfo("lancewu",new String[]{"1321134","man","Taiwan"});
addInfo("kandyli",new String[]{"12345"});
}
public void addInfo(String p,String[] c){
group.add(p);
List<String> item = new ArrayList<String>();
for(int i=0;i<c.length;i++){
item.add(c[i]);
}
child.add(item);
}
3. 定义BaseExpandableListAdapter 并与List<String> List<List<String>> 数据相适配
public class InfoDetailsAdapter extends BaseExpandableListAdapter {
Activity activity;
public InfoDetailsAdapter(Activity a){
activity = a;
}
//child method stub
@Override
public Object getChild(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return child.get(groupPosition).get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return childPosition;
}
@Override
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
return child.get(groupPosition).size();
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
String string = child.get(groupPosition).get(childPosition);
return getGenericView(string);
}
//group method stub
@Override
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return group.get(groupPosition);
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return group.size();
}
@Override
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
String string = group.get(groupPosition);
return getGenericView(string);
}
//View stub to create Group/Children 's View
public TextView getGenericView(String s) {
// Layout parameters for the ExpandableListView
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 64);
TextView text = new TextView(activity);
text.setLayoutParams(lp);
// Center the text vertically
text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
// Set the text starting position
text.setPadding(36, 0, 0, 0);
text.setText(s);
return text;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return true;
}
}
4. emulator 运行截图:
5. 下面说一下 数据更新 问题 包括:添加数据 删除数据
* 定义添加数据界面:add.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名:"
/>
<EditText
android:id="@+id/add_name"
android:layout_width="200dip"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="电话:"
/>
<EditText
android:id="@+id/add_phone"
android:layout_width="200dip"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别:"
/>
<EditText
android:id="@+id/add_sex"
android:layout_width="200dip"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="住址:"
/>
<EditText
android:id="@+id/add_home"
android:layout_width="200dip"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/add_ok"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:text="OK"
/>
<Button
android:id="@+id/add_no"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:text="NO"
/>
</LinearLayout>
</LinearLayout>
* add.xml 里 View 的定义:
public void createDialogAdd(){
viewAdd = this.getLayoutInflater().inflate(R.layout.add, null);
dialogAdd = new Dialog(this);
dialogAdd.setContentView(viewAdd);
dialogAdd.setTitle("输入新成员信息");
add_name = (EditText)viewAdd.findViewById(R.id.add_name);
add_phone = (EditText)viewAdd.findViewById(R.id.add_phone);
add_sex = (EditText)viewAdd.findViewById(R.id.add_sex);
add_home = (EditText)viewAdd.findViewById(R.id.add_home);
add_ok = (Button)viewAdd.findViewById(R.id.add_ok);
add_no = (Button)viewAdd.findViewById(R.id.add_no);
add_ok.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
String[] data = {
add_phone.getText().toString(),
add_sex.getText().toString(),
add_home.getText().toString()
};
addInfo(add_name.getText().toString(),data);
dialogAdd.dismiss();
mAdapter.notifyDataSetChanged();
}
});
add_no.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
dialogAdd.dismiss();
}
});
}
* 运行截图:
* 定义删除数据界面:delete.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ID:"
/>
<EditText
android:id="@+id/delete_id"
android:layout_width="200dip"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/delete_ok"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:text="OK"
/>
<Button
android:id="@+id/delete_no"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:text="NO"
/>
</LinearLayout>
</LinearLayout>
* delete.xml 里View 定义:
public void createDialogDelete(){
viewDelete = this.getLayoutInflater().inflate(R.layout.delete, null);
dialogDelete = new Dialog(this);
dialogDelete.setContentView(viewDelete);
dialogDelete.setTitle("删除指定成员");
delete_id = (EditText)viewDelete.findViewById(R.id.delete_id);
delete_ok = (Button)viewDelete.findViewById(R.id.delete_ok);
delete_no = (Button)viewDelete.findViewById(R.id.delete_no);
delete_ok.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
String id = delete_id.getText().toString();
if(! id.equals("")){
int i = Integer.parseInt(id);
group.remove(i);
child.remove(i);
dialogDelete.dismiss();
mAdapter.notifyDataSetChanged();
}
}
});
delete_no.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
dialogDelete.dismiss();
}
});
}
* 运行截图:
最后 说一下ExpandableListView的回调函数 用于监听那个id 被expand
expandList.setOnGroupClickListener(new OnGroupClickListener(){
@Override
public boolean onGroupClick(ExpandableListView arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(activity,"[Group Click]:"+arg2,Toast.LENGTH_LONG).show();
return false;
}
});
expandList.setOnChildClickListener(new OnChildClickListener(){
@Override
public boolean onChildClick(ExpandableListView arg0, View arg1,
int arg2, int arg3, long arg4) {
// TODO Auto-generated method stub
Toast.makeText(activity,"[Child Click]:"+arg2+":"+arg3,Toast.LENGTH_LONG).show();
return false;
}
});
1 楼
luyi-jn
2010-08-04
经典,保存了,多谢
2 楼
liangtiaolong
2010-08-09
附件为什么不能下载了啦???
3 楼
xtcpcgx
2010-08-24
收藏,很好的资料,正要学习这一部分
4 楼
tjayy
2010-10-03
正好看到这个控件 有点疑问 看了代码很不错 学习了
5 楼
happy200318
2010-10-17
刚好用到这个控件,多谢你的教程!~谢谢
6 楼
liuqun_567
2010-10-29
太经典了,多谢了,太有帮助了
7 楼
tianyw
2010-11-01
正在犯愁怎么做,谢谢,学习啦!
顶你!!
顶你!!
8 楼
蓝月儿
2010-12-05
这么全,好几个难点都让您帮忙点化了 呵呵
9 楼
sendy618
2010-12-18
不错 哈哈 收藏! 。。。
10 楼
彩虹神
2011-01-20
有没有办法控制改变它的默认界面,这个默认的实在是太丑了,怎么美化呢?
11 楼
chensylsl
2011-02-16
我找了好久了 谢谢 哈哈
12 楼
chensylsl
2011-02-16
这个控件非常不错 收藏起来了
13 楼
david25231
2011-02-17
好东西。。。谢了
14 楼
yuyafly
2012-01-11
不错
[3] menu.addIntentOptions 增添动态菜单
来源: 互联网 发布时间: 2014-02-18
menu.addIntentOptions 添加动态菜单
android的一个activity可以再选中某项之后按menu键弹出特定的菜单,也就是动态菜单。动态菜单的实现是靠menu类中的addIntentOptions函数实现的,具体的声明如下:
int android.view.Menu.addIntentOptions(
int groupId,
int itemId,
int order,
ComponentName caller,
Intent[] specifics,
Intent intent,
int flags,
MenuItem[] outSpecificItems)
这个函数是用来动态产生option menu的
函数参数分析:
1. groupid 就是菜单组的编号;
2. itemId (可以让其为0)
3. order 菜单顺序,可以不考虑
4. Caller 就是发起activity的activity
5. Specifics 以action+uri的具体方式来增加激活相应activity的菜单项
6. Intent 以categroy+uri这种一般形式来增加激活相应activity的菜单项
参数Intent和Specifics的区别是,一个用categroy+uri来匹配activity,一个用action+uri来匹配 activity。
8. outSpecificItems 这个是返回的MenuItem值,对应以specifics方式匹配的菜单项。
下面以android sdk中notepad的例子来说明其用法。
来看这个例子中的NotesList.java 文件中的public boolean onPrepareOptionsMenu(Menu menu)函数,这个函数会在设定普通option menu菜单项的的onCreateOptionsMenu函数之后调用,这个函数的主要部分是如下代码:
view plaincopy to clipboardprint?
1. Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId());
2.
3.
4. Intent[] specifics = new Intent[1];
5. specifics[0] = new Intent(Intent.ACTION_EDIT, uri);
6. MenuItem[] items = new MenuItem[1];
7.
8.
9. Intent intent = new Intent(null, uri);
10. intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
11. menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0,
12. items);
Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId()); Intent[] specifics = new Intent[1]; specifics[0] = new Intent(Intent.ACTION_EDIT, uri); MenuItem[] items = new MenuItem[1]; Intent intent = new Intent(null, uri); intent.addCategory(Intent.CATEGORY_ALTERNATIVE); menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0, items);
其中 ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId())会得到选中项的信息,这个信息将会作用匹配用的intent的
data部分。
specifics[0] = new Intent(Intent.ACTION_EDIT, uri)在这里是这个意思:到androidMenifest.xml中去找activity, 如果有某个activity的<intent-
filter>项的action和data与Intent.ACTION_EDIT和相应的uri匹配,就为这个activity添加一个菜单项,菜单项的显示名称从相应 activity的
android:label项得来。
Intent intent = new Intent(null, uri);
intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
是这个意思:到androidMenifest.xml中去找activity,如果有某些 activity的<intent-filter>项的Category和data与
Intent.CATEGORY_ALTERNATIVE和相应的uri匹配,就为这些activity分别添加菜单项,菜单项的显示名称从相应activity的android:label项
得来。
下面可以做个试验,在AndroidMenifest.xml中新建一个activity MyAdd
view plaincopy to clipboardprint?
1. <activity android:name="MyAdd" android:label="@string/title_myadd"
2. android:windowSoftInputMode="stateVisible">
3. <intent-filter android:label="@string/resolve_myadd">
4. <action android:name="com.android.notepad.action.MYADD" />
5. <category android:name="android.intent.category.ALTERNATIVE" />
6. <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
7. </intent-filter>
8. </activity>
<activity android:name="MyAdd" android:label="@string/title_myadd" android:windowSoftInputMode="stateVisible"> <intent-filter android:label="@string/resolve_myadd"> <action android:name="com.android.notepad.action.MYADD" /> <category android:name="android.intent.category.ALTERNATIVE" /> <data android:mimeType="vnd.android.cursor.item/vnd.google.note" /> </intent-filter> </activity>
写好该activity的layout和实现后,选中noteslist中的一项后,点 menu可以看到菜单中多出了一项,点击可以切换到该activity。
这是以函数中Intent匹配的菜单项,当然也可以用Specifics来匹配。下面示例:
删除掉MyAdd这个activity中的 <category android:name="android.intent.category.ALTERNATIVE" />,这时该activity已经与Intent不匹配了,
再将onPrepareOptionsMenu 函数中的代码改成如下:
view plaincopy to clipboardprint?
1. Intent[] specifics = new Intent[2];
2. specifics[0] = new Intent(Intent.ACTION_VIEW, uri);
3. specifics[1] = new Intent("com.android.notepad.action.MYADD",uri);
4. MenuItem[] items = new MenuItem[2];
Intent[] specifics = new Intent[2]; specifics[0] = new Intent(Intent.ACTION_VIEW, uri); specifics[1] = new Intent("com.android.notepad.action.MYADD",uri); MenuItem[] items = new MenuItem[2];
选中一项点菜会发现,动态菜单又回来了,不过这次是用Specific来匹配的。
android的一个activity可以再选中某项之后按menu键弹出特定的菜单,也就是动态菜单。动态菜单的实现是靠menu类中的addIntentOptions函数实现的,具体的声明如下:
int android.view.Menu.addIntentOptions(
int groupId,
int itemId,
int order,
ComponentName caller,
Intent[] specifics,
Intent intent,
int flags,
MenuItem[] outSpecificItems)
这个函数是用来动态产生option menu的
函数参数分析:
1. groupid 就是菜单组的编号;
2. itemId (可以让其为0)
3. order 菜单顺序,可以不考虑
4. Caller 就是发起activity的activity
5. Specifics 以action+uri的具体方式来增加激活相应activity的菜单项
6. Intent 以categroy+uri这种一般形式来增加激活相应activity的菜单项
参数Intent和Specifics的区别是,一个用categroy+uri来匹配activity,一个用action+uri来匹配 activity。
8. outSpecificItems 这个是返回的MenuItem值,对应以specifics方式匹配的菜单项。
下面以android sdk中notepad的例子来说明其用法。
来看这个例子中的NotesList.java 文件中的public boolean onPrepareOptionsMenu(Menu menu)函数,这个函数会在设定普通option menu菜单项的的onCreateOptionsMenu函数之后调用,这个函数的主要部分是如下代码:
view plaincopy to clipboardprint?
1. Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId());
2.
3.
4. Intent[] specifics = new Intent[1];
5. specifics[0] = new Intent(Intent.ACTION_EDIT, uri);
6. MenuItem[] items = new MenuItem[1];
7.
8.
9. Intent intent = new Intent(null, uri);
10. intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
11. menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0,
12. items);
Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId()); Intent[] specifics = new Intent[1]; specifics[0] = new Intent(Intent.ACTION_EDIT, uri); MenuItem[] items = new MenuItem[1]; Intent intent = new Intent(null, uri); intent.addCategory(Intent.CATEGORY_ALTERNATIVE); menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0, items);
其中 ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId())会得到选中项的信息,这个信息将会作用匹配用的intent的
data部分。
specifics[0] = new Intent(Intent.ACTION_EDIT, uri)在这里是这个意思:到androidMenifest.xml中去找activity, 如果有某个activity的<intent-
filter>项的action和data与Intent.ACTION_EDIT和相应的uri匹配,就为这个activity添加一个菜单项,菜单项的显示名称从相应 activity的
android:label项得来。
Intent intent = new Intent(null, uri);
intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
是这个意思:到androidMenifest.xml中去找activity,如果有某些 activity的<intent-filter>项的Category和data与
Intent.CATEGORY_ALTERNATIVE和相应的uri匹配,就为这些activity分别添加菜单项,菜单项的显示名称从相应activity的android:label项
得来。
下面可以做个试验,在AndroidMenifest.xml中新建一个activity MyAdd
view plaincopy to clipboardprint?
1. <activity android:name="MyAdd" android:label="@string/title_myadd"
2. android:windowSoftInputMode="stateVisible">
3. <intent-filter android:label="@string/resolve_myadd">
4. <action android:name="com.android.notepad.action.MYADD" />
5. <category android:name="android.intent.category.ALTERNATIVE" />
6. <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
7. </intent-filter>
8. </activity>
<activity android:name="MyAdd" android:label="@string/title_myadd" android:windowSoftInputMode="stateVisible"> <intent-filter android:label="@string/resolve_myadd"> <action android:name="com.android.notepad.action.MYADD" /> <category android:name="android.intent.category.ALTERNATIVE" /> <data android:mimeType="vnd.android.cursor.item/vnd.google.note" /> </intent-filter> </activity>
写好该activity的layout和实现后,选中noteslist中的一项后,点 menu可以看到菜单中多出了一项,点击可以切换到该activity。
这是以函数中Intent匹配的菜单项,当然也可以用Specifics来匹配。下面示例:
删除掉MyAdd这个activity中的 <category android:name="android.intent.category.ALTERNATIVE" />,这时该activity已经与Intent不匹配了,
再将onPrepareOptionsMenu 函数中的代码改成如下:
view plaincopy to clipboardprint?
1. Intent[] specifics = new Intent[2];
2. specifics[0] = new Intent(Intent.ACTION_VIEW, uri);
3. specifics[1] = new Intent("com.android.notepad.action.MYADD",uri);
4. MenuItem[] items = new MenuItem[2];
Intent[] specifics = new Intent[2]; specifics[0] = new Intent(Intent.ACTION_VIEW, uri); specifics[1] = new Intent("com.android.notepad.action.MYADD",uri); MenuItem[] items = new MenuItem[2];
选中一项点菜会发现,动态菜单又回来了,不过这次是用Specific来匹配的。
1 楼
alls4u
2011-03-02
有三个问题:
1、在“specifics[0] = new Intent(Intent.ACTION_EDIT, uri)在这里是这个意思:到androidMenifest.xml中去找activity, 如果有某个activity的<intent-filter>项的action和data与Intent.ACTION_EDIT和相应的uri匹配,就为这个activity添加一个菜单项
”中,intent-filter的匹配是action 和 data同时满足吗?两者是与的关系还是或的关系?
2、在NotePad里面,这个Uri你可以用打日志的方式打出来:
Log.i("default uri","" + uri);结果是:content://com.google.provider.NotePad/notes/1,这个Uri是怎么与AndroidManifest.xml中的data“vnd.android.cursor.item/vnd.google.note”对应的?
3、“菜单项的显示名称从相应activity的android:label项得来”,这句话是不正确的,其实是从匹配的intent-filter中的label得到的。
谢谢回答
1、在“specifics[0] = new Intent(Intent.ACTION_EDIT, uri)在这里是这个意思:到androidMenifest.xml中去找activity, 如果有某个activity的<intent-filter>项的action和data与Intent.ACTION_EDIT和相应的uri匹配,就为这个activity添加一个菜单项
”中,intent-filter的匹配是action 和 data同时满足吗?两者是与的关系还是或的关系?
2、在NotePad里面,这个Uri你可以用打日志的方式打出来:
Log.i("default uri","" + uri);结果是:content://com.google.provider.NotePad/notes/1,这个Uri是怎么与AndroidManifest.xml中的data“vnd.android.cursor.item/vnd.google.note”对应的?
3、“菜单项的显示名称从相应activity的android:label项得来”,这句话是不正确的,其实是从匹配的intent-filter中的label得到的。
谢谢回答
最新技术文章: