package mars.helloworld;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class HelloActivity extends Activity {
/** Called when the activity is first created. */
private TextView one_text;
private Button button1 = null;
private Button button2 = null;
private Button button3 = null;
private int n = 0;
private Intent intent = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
one_text = (TextView) findViewById(R.id.text_id);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
one_text.setText("用于显示的文本");
button1.setText("点击");
// button1.setBackgroundColor(200);
this.setVolumeControlStream(R.drawable.laonanhai);
// 添加背景音乐
intent = new Intent("com.angel.Android.MUSIC");
this.startService(intent);
button1.setOnClickListener(new MyButtonListener());
button2.setOnClickListener(new MyButtonListener());
button3.setOnClickListener(new MyButtonListener());
}
class MyButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
if (v == button1) {
if ("点击".equals(button1.getText())) {
button1.setText("恢复");
} else {
button1.setText("点击");
}
one_text.setText("按钮被单击" + (++n) + "次");
} else if (v == button2) {
intent = new Intent();
intent.putExtra("username", "zlp");
intent.setClass(HelloActivity.this, OtherActivity.class);
startActivity(intent);
} else if (v == button3) {
intent = new Intent();
Uri smsToUri = Uri.parse("smsto://15004168581");
intent = new Intent(Intent.ACTION_SENDTO, smsToUri);
intent.putExtra("sms_body", "shenrenkui");
// intent.setClass(HelloActivity.this, OtherActivity.class);
startActivity(intent);
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
HelloWorld.rar (29个子文件)
HelloWorld
.project 846B
default.properties 362B
bin
mars
helloworld
R$string.class 579B
R$layout.class 414B
MusicServer.class 1KB
R$drawable.class 424B
OtherActivity.class 1KB
R.class 510B
R$attr.class 331B
HelloActivity.class 3KB
R$id.class 506B
HelloActivity$MyButtonListener.class 3KB
HelloWorld.apk 6.88MB
resources.ap_ 6.88MB
classes.dex 7KB
proguard.cfg 1KB
AndroidManifest.xml 1KB
src
mars
helloworld
HelloActivity.java 2KB
OtherActivity.java 759B
MusicServer.java 793B
res
values
strings.xml 530B
layout
other.xml 364B
main.xml 784B
drawable-ldpi
icon.png 2KB
drawable-hdpi
laonanhai.mp3 6.87MB
icon.png 4KB
drawable-mdpi
icon.png 3KB
.classpath 280B
gen
mars
helloworld
R.java 1KB
assets
共 29 条
- 1
资源评论
- thebossforme2012-07-26小案例,背景音乐,按钮事件 intent数据传递还不错
那时花开
- 粉丝: 104
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功