android使用ComponentName组件简单示例
来源:互联网 发布:java实现快速排序算法 编辑:程序博客网 时间:2024/06/18 07:11
Intent中可以直接使用Intent.setClass(),也可以使用组件Component
简单的使用方式如下:
package com.example.test;import android.os.Bundle;import android.app.Activity;import android.content.ComponentName;import android.content.Intent;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button btn = (Button) findViewById(R.id.btn);btn.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent = new Intent();//1.利用setClass//intent.setClass(MainActivity.this, SencondActivity.class);//2.利用setComponent ComponentName的第一个参数必须是application's package name,也是主配置文件Manifest里设置好的包名ComponentName name = new ComponentName(getPackageName(), SencondActivity.class.getName());intent.setComponent(name);startActivity(intent);}});}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.activity_main, menu);return true;}}
- android使用ComponentName组件简单示例
- android使用ComponentName组件简单示例
- android使用ComponentName组件简单示例
- android示例之ComponentName
- Android ComponentName的使用
- Android 中使用 ComponentName 类
- Android中ComponentName的简单运用
- Android ComponentName
- Android ComponentName
- ComponentName使用
- android ComponentName的使用 之app交互
- Android SQLite 简单使用示例
- android组件GridView简单使用
- Android中app之间的交互(二,使用ComponentName)
- Android ComponentName的用法
- Android ComponentName的用法
- Android ComponentName的用法
- Android ComponentName的用法
- C++语言实现的WebService开发库—gsoap应用介绍
- linux下访问mysql的类
- Java中关于ArrayList中删除元素陷阱
- Redis应用案例,查找某个值的范围
- html下属性节点
- android使用ComponentName组件简单示例
- linux 工作队列
- Html中表格行的拖动
- linux下搭建配置mysql数据库
- 在windows内核模式下隐藏进程
- C++ 标准头文件与C头文件区别与联系以及C风格字符串
- 设计模式12:类适配器【结构型】
- MySQL API访问mysql数据库
- ubuntu下用Pip安装python拓展包