package com.yarin.android.RingProfile;
//Download by http://www.codefans.net
import java.util.Date;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.TimePicker;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost.OnTabChangeListener;
public class RingProfile extends TabActivity
{
private static final String TAG="RingToggle";
//声明TabHost对象
private TabHost mTabHost;
protected boolean isChange;
private AlarmManager mAlarmManager;
private TimePicker mTimePicker ;
private int mTab;
private ImageView myImage;
private ImageButton downButton;
private ImageButton upButton;
private ImageButton normalButton;
private ImageButton muteButton;
private ImageButton vibrateButton;
private ProgressBar myProgress;
private AudioManager audioMa;
private int volume = 0;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//取得TabHost对象
mTabHost = getTabHost();
/* 为TabHost添加标签 */
//新建一个newTabSpec(newTabSpec)
//设置其标签和图标(setIndicator)
//设置内容(setContent)
mTabHost.addTab(mTabHost.newTabSpec("tab_test1")
.setIndicator("普通情景模式",getResources().getDrawable(R.drawable.icon))
.setContent(R.id.RadioGroup01));
mTabHost.addTab(mTabHost.newTabSpec("tab_test2")
.setIndicator("定时情景模式",getResources().getDrawable(R.drawable.timeprofile))
.setContent(R.id.RelativeLayout01));
mTabHost.addTab(mTabHost.newTabSpec("tab_test3")
.setIndicator("自定义情景模式",getResources().getDrawable(R.drawable.addprofile))
.setContent(R.id.AbsoluteLayout03));
//设置TabHost的背景图片资源
mTabHost.setBackgroundResource(R.drawable.bg);
//设置当前显示哪一个标签
mTabHost.setCurrentTab(0);
mTab = 0;
updateRadioGroup();
//初始化,取得AudioManager
audioMa = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
myImage = (ImageView)findViewById(R.id.myImage);
myProgress = (ProgressBar)findViewById(R.id.myProgress);
downButton = (ImageButton)findViewById(R.id.downButton);
upButton = (ImageButton)findViewById(R.id.upButton);
normalButton = (ImageButton)findViewById(R.id.normalButton);
muteButton = (ImageButton)findViewById(R.id.muteButton);
vibrateButton = (ImageButton)findViewById(R.id.vibrateButton);
//标签切换事件处理,setOnTabChangedListener
mTabHost.setOnTabChangedListener(new OnTabChangeListener()
{
@Override
public void onTabChanged(String tabId)
{
if ( tabId.equals("tab_test1") )
{
mTab = 0;
mAlarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
mTimePicker = (TimePicker)findViewById(R.id.timePkr);
mTimePicker.setIs24HourView(true);
updateRadioGroup();
}
else if ( tabId.equals("tab_test2") )
{
mTab = 1;
mAlarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
mTimePicker = (TimePicker)findViewById(R.id.timePkr);
mTimePicker.setIs24HourView(true);
updateRadioGroup();
}
}
});
/***************************************************************/
RadioGroup group1 = (RadioGroup) findViewById(R.id.RadioGroup01);
group1.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId)
{
if (isChange)
return;
switch (checkedId)
{
case R.id.ring_and_vibrate01: ringAndVibrate(); break;
case R.id.ring01: ring(); break;
case R.id.vibrate01: vibrate(); break;
case R.id.silent01: silent(); break;
}
RadioButton radio = (RadioButton) findViewById(checkedId);
if (radio != null)
radio.setTextSize(30);
}
});
//RadioButton添加监听器
for (int i = 0, l = group1.getChildCount(); i < l; i++)
{
RadioButton radio = (RadioButton) group1.getChildAt(i);
radio.setOnTouchListener(new OnTouchListener()
{
public boolean onTouch(View v, MotionEvent event)
{
RadioButton radio = (RadioButton) v;
if (!radio.isChecked())
return false;
radio.setTextSize(30);
return false;
}
});
}
/***************************************************************/
//添加onChangeListener
RadioGroup group2 = (RadioGroup) findViewById(R.id.RadioGroup02);
group2.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId)
{
if (isChange)
return;
switch (checkedId)
{
case R.id.ring_and_vibrate02: ringAndVibrate(); break;
case R.id.ring02: ring(); break;
case R.id.vibrate02: vibrate(); break;
case R.id.silent02: silent(); break;
}
RadioButton radio = (RadioButton) findViewById(checkedId);
if (radio != null)
radio.setTextSize(30);
}
});
//RadioButton添加监听器
for (int i = 0, l = group2.getChildCount(); i < l; i++)
{
RadioButton radio = (RadioButton) group2.getChildAt(i);
radio.setOnTouchListener(new OnTouchListener()
{
public boolean onTouch(View v, MotionEvent event)
{
RadioButton radio = (RadioButton) v;
if (!radio.isChecked())
return false;
radio.setTextSize(30);
return false;
}
});
}
//取得手机的初始音量,并初始化进度条
volume=audioMa.getStreamVolume(AudioManager.STREAM_RING);
myProgress.setProgress(volume);
//取得初始模式,并分别设置图标
int mode=audioMa.getRingerMode();
if(mode==AudioManager.RINGER_MODE_NORMAL)
{
myImage.setImageDrawable(getResources()
.getDrawable(R.drawable.icon));
没有合适的资源?快使用搜索试试~ 我知道了~
6个Android源码实例
共212个文件
class:90个
java:30个
png:28个
5星 · 超过95%的资源 需积分: 9 695 下载量 113 浏览量
2013-06-02
14:16:59
上传
评论 16
收藏 660KB RAR 举报
温馨提示
6个基础的Android源码实例,主要是城市天气预报CityWeather Android源码,移动地图MobileMap源代码,MusicPlayer音乐播放器源代码,MyContacts通讯录源代码,RingProfile手机铃声设置,TodayDate Android日历源代码,都是比较小的源码,希望对学习android的朋友有帮助。
资源推荐
资源详情
资源评论
收起资源包目录
6个Android源码实例 (212个子文件)
resources.ap_ 48KB
resources.ap_ 44KB
resources.ap_ 26KB
resources.ap_ 13KB
resources.ap_ 11KB
resources.ap_ 10KB
MyContacts.apk 60KB
RingProfile.apk 52KB
MobileMap.apk 36KB
CityWeather.apk 20KB
TodayDate.apk 17KB
MusicPlayer.apk 17KB
MobileMap.class 9KB
RingProfile.class 9KB
ContactEditor.class 7KB
ContactsProvider.class 7KB
MyContacts.class 7KB
CityWeather.class 5KB
MusicList.class 5KB
ContactView.class 4KB
LocationOverlay.class 4KB
GoogleWeatherHandler.class 4KB
MusicPlayerService.class 3KB
TodayDate.class 3KB
ConstData.class 3KB
ConstData.class 3KB
TodayDateSmall.class 3KB
SingleWeatherInfoView.class 2KB
RingBroadcastReceiver.class 2KB
MusicListAdapter.class 2KB
WeatherCurrentCondition.class 2KB
RingProfile$7.class 2KB
RingProfile$6.class 2KB
MobileMap$2.class 2KB
MusicInfoController.class 2KB
CityWeather$1.class 2KB
RingProfile$1.class 2KB
RingProfile$10.class 2KB
RingProfile$8.class 2KB
RingProfile$9.class 2KB
WeatherForecastCondition.class 2KB
CityWeather$2.class 2KB
MusicList$2.class 1KB
DBHelper.class 1KB
WeatherSet.class 1KB
MusicList$4.class 1KB
MobileMap$4.class 1KB
RingProfile$2.class 1KB
RingProfile$4.class 1KB
ContactEditor$1.class 1KB
MusicList$3.class 1KB
R$id.class 1KB
MusicList$1.class 1KB
MobileMap$3.class 1KB
MobileMap$1.class 1KB
R$id.class 1KB
R$id.class 1KB
ContactColumn.class 1KB
RingProfile$3.class 1KB
RingProfile$5.class 1KB
ContactEditor$2.class 1KB
MusicPlayerService$1.class 1023B
MusicPlayerService$2.class 1012B
R$string.class 920B
MobileMap$5.class 886B
MobileMap$6.class 866B
MusicPlayerApp.class 863B
MusicPlayerService$LocalBinder.class 733B
R$drawable.class 700B
R.class 667B
R.class 647B
R$drawable.class 641B
R.class 608B
R.class 608B
R.class 601B
R.class 594B
R$string.class 588B
R$string.class 585B
R$drawable.class 579B
R$id.class 558B
R$drawable.class 547B
R$id.class 530B
R$string.class 516B
R$id.class 482B
R$layout.class 473B
R$layout.class 466B
R$string.class 463B
R$drawable.class 459B
R$drawable.class 459B
R$string.class 454B
R$color.class 453B
R$layout.class 451B
R$xml.class 450B
R$layout.class 434B
R$layout.class 427B
R$layout.class 427B
R$attr.class 373B
R$attr.class 373B
R$attr.class 373B
R$attr.class 370B
共 212 条
- 1
- 2
- 3
godpower888
- 粉丝: 14
- 资源: 72
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页