package xyz.Hello;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.widget.CompoundButton;
import android.widget.ToggleButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class HelloWorldActivity extends Activity {
/** Called when the activity is first created. */
private ToggleButton BatteryCheck;
private TextView TextShow;
private Button Button_Inf;
private BatteryListener BatteryListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button_Inf = (Button)findViewById(R.id.button_Inf);
BatteryCheck = (ToggleButton)findViewById(R.id.batteryCheck);
TextShow = (TextView)findViewById(R.id.textShow);
BatteryListener = new BatteryListener();
Button_Inf.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View x)
{
Button_Inf.setText("By 蓝海哨兵");
}
});
BatteryCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
//@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if(isChecked)
{
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(BatteryListener,filter);
}
else
{
unregisterReceiver(BatteryListener);
TextShow.setText("谢谢使用");
}
}
});
}
private class BatteryListener extends BroadcastReceiver {
@Override
public void onReceive(Context context,Intent intent){
int current = intent.getExtras().getInt("level");
int totle = intent.getExtras().getInt("scale");
int percent = current*100/totle;
TextShow.setText("电量剩余"+percent+"%");
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
HelloWorld.rar (36个子文件)
HelloWorld
AndroidManifest.xml 734B
res
layout
main.xml 1KB
drawable-ldpi
xyz.png 4KB
ic_launcher.png 2KB
drawable
xyz.png 4KB
drawable-mdpi
xyz.png 4KB
ic_launcher.png 3KB
drawable-hdpi
xyz.png 4KB
ic_launcher.png 4KB
values
strings.xml 174B
proguard.cfg 1KB
src
xyz
Hello
HelloWorldActivity.java 2KB
bin
classes
xyz
Hello
HelloWorldActivity$1.class 953B
HelloWorldActivity.class 2KB
R.class 468B
R$layout.class 367B
R$attr.class 313B
HelloWorldActivity$2.class 2KB
R$id.class 429B
R$string.class 400B
HelloWorldActivity$BatteryListener.class 2KB
R$drawable.class 407B
res
drawable-ldpi
ic_launcher.png 2KB
drawable
drawable-mdpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
classes.dex 5KB
HelloWorld.apk 34KB
resources.ap_ 29KB
.classpath 364B
hs_err_pid3776.log 5KB
assets
project.properties 360B
hs_err_pid3140.log 5KB
.project 846B
gen
xyz
Hello
R.java 898B
hs_err_pid2804.log 5KB
hs_err_pid3028.log 5KB
共 36 条
- 1
资源评论
- 要饭猫2015-06-01界面简洁,有待改善啊,不过还不错
Xyz_123
- 粉丝: 2
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功