点击(此处)折叠或打开
-
package org.lxh.demo;
-
import android.app.Activity;
-
import android.content.Intent;
-
import android.os.Bundle;
-
import android.view.View;
-
import android.view.View.OnClickListener;
-
import android.widget.Button;
-
public class MyBroadcastDemo extends Activity {
-
private Button mybut ; // 按钮组件
-
@Override
-
public void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
-
super.setContentView(R.layout.main); // 设置默认布局管理器
-
this.mybut = (Button) super.findViewById(R.id.mybut) ; // 取得组件
-
this.mybut.setOnClickListener(new OnClickListenerImpl()); // 设置监听
-
}
-
private class OnClickListenerImpl implements OnClickListener {
-
@Override
-
public void onClick(View v) {
-
Intent it = new Intent(Intent.ACTION_EDIT); // 启动Action
-
MyBroadcastDemo.this.sendBroadcast(it); // 进行广播
-
}
-
}
- }