与MCU通讯,实现Radio收音机功能,初级项目

package com.example.textradio;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.mcucom.McuComAddr;
import android.mcucom.McuComKey;
import android.mcucom.McuComManager;
import android.mcucom.McuComSysState;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Surface;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.WindowManager;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

@SuppressLint("NewApi")
public class MainActivity extends Activity implements OnClickListener{

	private ImageButton up,down,prev,search,band,next;
	private TextView cur_freq,t_band,hz;
	private boolean ButtonPressed = true;
	private Timer mButtonTimer = null;
	private int Items = -1;
	private static McuComManager gMCM = null;

	private SeekBar main_seekbar_band;
	//ch1
	private ImageView back1,MpinpuOne,b_p1;
	private TextView MchOne = null;
	private RelativeLayout rl_1;
	//ch2
	private ImageView back2,MpinpuTwo,b_p2 = null;
	private TextView MchTwo = null;
	private RelativeLayout rl_2;
	//ch3
	private ImageView back3,MpinpuThree,b_p3= null;
	private TextView MchThree = null;
	private RelativeLayout rl_3;
	//ch4
	private ImageView back4 ,MpinpuFour,b_p4= null;
	private TextView MchFour = null;
	private RelativeLayout rl_4;
	//ch5
	private ImageView back5,MpinpuFive,b_p5 = null;
	private TextView MchFive = null;
	private RelativeLayout rl_5;
	//ch6
	private ImageView back6,MpinpuSix,b_p6= null;
	private TextView MchSix = null;
	private RelativeLayout rl_6;

	private static int[] g_radio_freqlist  = new int[6];
	private static final int RADIO_BAND_FM1 = 0;
	private static final int RADIO_BAND_FM2 = 1;
	private static final int RADIO_BAND_FM3 = 2;
	private static final int RADIO_BAND_AM1 = 3;
	private static final int RADIO_BAND_AM2 = 4;
	private static final String TAG = null;
	private AnimationDrawable anim1,anim2,anim3,anim4,anim5,anim6;

	public RadioHandler mRadioHandler;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		mRadioHandler = new RadioHandler();
		Locale locale = new Locale("America/Los_Angeles");//洛杉矶
		DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);//封装数据本地化
		Format = new DecimalFormat(".00",symbols);
		//	this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
		intView();
		setView();
		ShowSeekBar();
		if (null == gMCM)
			gMCM = new McuComManager();
		if (null != gMCM)
		{
			g_sys_state = gMCM.getSystemState();//系统状态
			if(g_sys_state!=McuComSysState.CAR_MPEG_SYS_POWEROFF)
			{
				str_rds_text = gMCM.getRdsMessage();

				if(g_sys_state != McuComSysState.CAR_MPEG_SYS_RADIO)
				{
					g_sys_state = McuComSysState.CAR_MPEG_SYS_RADIO;
					gMCM.setSystemState(g_sys_state);
					byte[] data = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORTKEY, McuComKey.CAR_KEY_RADIO_SEL);
					send_command(McuComAddr.CAR_MPEG_KEY_ADR, data);
				}
				gMCM.changeAudioInput(3);
				gMCM.setMcuComClient();
				gMCM.setOnActionListener(mRadioAction);
				gMCM.setOnActionStringListener(mRadioStringAction);
				Log.i(TAG, "=====McuComManager==ok==");//初始化M
			}
		}
	}

	private void intView() {
		up=(ImageButton) findViewById(R.id.up);
		down=(ImageButton) findViewById(R.id.down);
		prev=(ImageButton) findViewById(R.id.prev);
		search=(ImageButton) findViewById(R.id.search);
		band=(ImageButton) findViewById(R.id.band);
		next=(ImageButton) findViewById(R.id.next);
		cur_freq=(TextView) findViewById(R.id.cur_freq);
		t_band=(TextView) findViewById(R.id.t_band);
		hz=(TextView) findViewById(R.id.hz);
		main_seekbar_band=(SeekBar) this.findViewById(R.id.main_seekbar_band);
		main_seekbar_band.setMax(SEEKBAR_MAX);
		main_seekbar_band.setProgress(0);

		up.setOnClickListener( (OnClickListener) this);
		down.setOnClickListener((OnClickListener) this);
		prev.setOnClickListener((OnClickListener) this);
		search.setOnClickListener((OnClickListener) this);
		band.setOnClickListener((OnClickListener) this);
		next.setOnClickListener((OnClickListener) this);

		//ch1
		rl_1=(RelativeLayout) findViewById(R.id.layout_1);
		rl_1.setOnClickListener(ItemClick);
		rl_1.setOnLongClickListener(LongClick);
		back1 = (ImageView)findViewById(R.id.ch_back1);
		MpinpuOne = (ImageView)findViewById(R.id.pinpu_one);
		anim1 = (AnimationDrawable) MpinpuOne.getBackground();
		b_p1= (ImageView) findViewById(R.id.b_p1);
		MchOne = (TextView)findViewById(R.id.ch_one);
		//ch2
		rl_2=(RelativeLayout) findViewById(R.id.layout_2);
		rl_2.setOnClickListener(ItemClick);
		rl_2.setOnLongClickListener(LongClick);
		back2 = (ImageView)findViewById(R.id.ch_back2);
		MpinpuTwo = (ImageView)findViewById(R.id.pinpu_two);
		b_p2= (ImageView) findViewById(R.id.b_p2);
		anim2 = (AnimationDrawable) MpinpuTwo.getBackground();
		MchTwo = (TextView)findViewById(R.id.ch_two);
		//ch3
		rl_3=(RelativeLayout) findViewById(R.id.layout_3);
		rl_3.setOnClickListener(ItemClick);
		rl_3.setOnLongClickListener(LongClick);
		back3 = (ImageView)findViewById(R.id.ch_back3);
		MpinpuThree = (ImageView)findViewById(R.id.pinpu_three);
		anim3 = (AnimationDrawable) MpinpuThree.getBackground();
		b_p3= (ImageView) findViewById(R.id.b_p3);
		MchThree = (TextView)findViewById(R.id.ch_three);
		//ch4
		rl_4=(RelativeLayout) findViewById(R.id.layout_4);
		rl_4.setOnClickListener(ItemClick);
		rl_4.setOnLongClickListener(LongClick);
		back4 = (ImageView)findViewById(R.id.ch_back4);
		MpinpuFour = (ImageView)findViewById(R.id.pinpu_four);
		b_p4= (ImageView) findViewById(R.id.b_p4);
		anim4 = (AnimationDrawable) MpinpuFour.getBackground();
		MchFour = (TextView)findViewById(R.id.ch_four);
		//ch5
		rl_5=(RelativeLayout) findViewById(R.id.layout_5);
		rl_5.setOnClickListener(ItemClick);
		rl_5.setOnLongClickListener(LongClick);
		back5 = (ImageView)findViewById(R.id.ch_back5);
		MpinpuFive = (ImageView)findViewById(R.id.pinpu_five);
		anim5 = (AnimationDrawable) MpinpuFive.getBackground();
		b_p5= (ImageView) findViewById(R.id.b_p5);
		MchFive = (TextView)findViewById(R.id.ch_five);
		//ch6
		rl_6=(RelativeLayout) findViewById(R.id.layout_6);
		rl_6.setOnClickListener(ItemClick);
		rl_6.setOnLongClickListener(LongClick);
		back6 = (ImageView)findViewById(R.id.ch_back6);
		MpinpuSix = (ImageView)findViewById(R.id.pinpu_six);
		anim6 = (AnimationDrawable) MpinpuSix.getBackground();
		MchSix = (TextView)findViewById(R.id.ch_six);
		b_p6= (ImageView) findViewById(R.id.b_p6);
	}

	private void setView() {
		if(getrot(this) != 90f){
			Intent intentRotated = new Intent("com.ATCSetting.mainui.rotationservice");
			intentRotated.putExtra("screen_rotated", true);
			startService(intentRotated);
		}		
	}

	private float getDegreesForRotation(int value) {
		switch (value) {
		case Surface.ROTATION_90:
			return 360f - 90f;
		case Surface.ROTATION_180:
			return 360f - 180f;
		case Surface.ROTATION_270:
			return 360f - 270f;
		}
		return 0f;
	}

	@SuppressLint("NewApi")
	public float getrot(Context mContext){
		WindowManager mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
		Display mDisplay = mWindowManager.getDefaultDisplay();
		DisplayMetrics mDisplayMetrics = new DisplayMetrics();
		mDisplay.getRealMetrics(mDisplayMetrics);   
		mDisplay.getRealMetrics(mDisplayMetrics);
		float degrees = getDegreesForRotation(mDisplay.getRotation());		
		return degrees;
	}
	public int FMORAM = 0;//fm--am
	private final int SEEKBAR_MAX = 1000;
	private  float SEEKBAR_FROM = 87.5f;
	private  float SEEKBAR_TO = 108.0f;

	private  float AM_SEEKBAR_FROM = 522;
	private  float AM_SEEKBAR_TO = 1620;
	private DecimalFormat Format;
	private int funFlag=0;

	public static byte[] Saw_Data(int value) {
		byte[] ret_saw = new byte[2];
		ret_saw[0] = (byte) ((value >> 8));
		ret_saw[1] = (byte) (value & 0xFF);
		return ret_saw;
	}

	public void sendCommand(int what, int arg)
	{
		Message msg = new Message();
		switch (what) {
		case McuComAddr.CAR_MPEG_KEY_ADR:
		case McuComAddr.CAR_MPEG_RADIO_BAND_ADR:
		case McuComAddr.CAR_MPEG_RADIO_AREA_ADR:
		case McuComAddr.CAR_MPEG_RADIO_CUR_FREQ_ADR:	
		case McuComAddr.CAR_MPEG_RADIO_FREQ_CH1_ADR:
		case McuComAddr.CAR_MPEG_RADIO_FREQ_CH2_ADR:
		case McuComAddr.CAR_MPEG_RADIO_FREQ_CH3_ADR:
		case McuComAddr.CAR_MPEG_RADIO_FREQ_CH4_ADR:
		case McuComAddr.CAR_MPEG_RADIO_FREQ_CH5_ADR:
		case McuComAddr.CAR_MPEG_RADIO_FREQ_CH6_ADR:
		case McuComAddr.CAR_MPEG_RADIO_FREQ_UPDATE_ADR:
		case McuComAddr.CAR_MPEG_RADIO_ST_ADR:
		case McuComAddr.CAR_MPEG_RADIO_LOC_ADR: 

			msg.what = what;
			msg.arg1 = arg;
			mRadioHandler.sendMessage(msg);
			break;
		case McuComAddr.CAR_MPEG_RADIO_RDSMSG_ADR:			
			break;
		case McuComAddr.CAR_MPEG_RADIO_RDS_PTY_ADR:	

			msg.what = what;
			msg.arg1 = arg;
			mRadioHandler.sendMessage(msg);			
			break;
		default:
			break;
		}
	}

	public static final int Enable_Rds= 0x20; 
	public static boolean bRds = false;
	public void checkRds()
	{

		Log.i("FDebug","checkRds()------------------------------gMCM="+gMCM);

		if(gMCM != null)
		{
			funFlag = gMCM.getSystemFlag();
			if((funFlag&Enable_Rds) == Enable_Rds)  bRds = true;
			else bRds = false;
		}
	}

	//返回数据
	private McuComManager.OnActionListener mRadioAction = new McuComManager.OnActionListener() {

		public int onAction(int adr, int data) {
			Log.i(TAG, "=====mRadioAction==adr=="+adr+"=data=="+data);
			switch(adr)
			{
			case McuComManager.SYS_UPDATE_KEY:
				sendCommand(McuComAddr.CAR_MPEG_KEY_ADR,data);
				break;
			case McuComManager.RADIO_UPDATE_FLAG:
				g_radio_flag = data;
				ProcessRadioFlag(g_radio_flag);
				sendCommand(McuComAddr.CAR_MPEG_RADIO_FLAG_ADR,data);
				sendCommand(McuComAddr.CAR_MPEG_RADIO_RDS_PTY_ADR,data);
				break;
			case McuComManager.RADIO_UPDATE_BAND:
				g_radio_bandstate = data;
				sendCommand(McuComAddr.CAR_MPEG_RADIO_BAND_ADR,data);
				break;
			case McuComManager.RADIO_UPDATE_AREA:
				g_radio_area = data;
				sendCommand(McuComAddr.CAR_MPEG_RADIO_AREA_ADR,data);
				break;
			case McuComManager.RADIO_UPDATE_CURFREQ:
				g_radio_curfreq = data;
				sendCommand(McuComAddr.CAR_MPEG_RADIO_CUR_FREQ_ADR,data);
				break;
			case McuComManager.RADIO_UPDATE_ALL:
				for(int i = 0; i < 6; i++)
				{
					g_radio_freqlist[i] = gMCM.getRadioFreqList(i);
					sendCommand(McuComAddr.CAR_MPEG_RADIO_FREQ_CH1_ADR+i,g_radio_freqlist[i]);
				}
				g_radio_area = (data&0xff00)>>8;
				g_radio_bandstate = data&0x00ff;
				sendCommand(McuComAddr.CAR_MPEG_RADIO_FREQ_UPDATE_ADR,g_radio_bandstate);
				break;
				case McuComManager.RADIO_UPDATE_STMODE:
					g_radio_stmode = data;
					sendCommand(McuComAddr.CAR_MPEG_RADIO_ST_ADR,data);
					break;
				case McuComManager.RADIO_UPDATE_LOCMODE:
					g_radio_locmode = data;
					sendCommand(McuComAddr.CAR_MPEG_RADIO_LOC_ADR,data);
					break;
			}
			return 0;
		}
	};

	//返回字符串类型的数据数据
	private McuComManager.OnActionStringListener mRadioStringAction = new McuComManager.OnActionStringListener() {
		public int onAction(int adr, String str) {
			switch(adr){
			case McuComManager.RADIO_UPDATE_RDSMSG:
				str_rds_text = str;
				sendCommand(McuComAddr.CAR_MPEG_RADIO_RDS_PTY_ADR,g_radio_flag);
				break;
			}
			return 0;
		}
	};

	private static byte g_radioflag_localmode = 0;
	private static byte g_radioflag_stmode = 0;
	private static byte g_radioflag_string = 0;
	private static byte g_radioflag_rdsmode = 0;
	private static byte g_radioflag_rdsta = 0;
	private static byte g_radioflag_rdstp = 0;
	private static byte g_radioflag_rdsaf = 0;
	private static byte g_radioflag_rdseon = 0;
	private static byte g_radioflag_autoscan = 0;
	private static byte g_radioflag_intro = 0;
	private static byte g_radioflag_autoscanup = 0;
	private static byte g_radioflag_mpegdiscin = 0;
	private static byte g_radioflag_mpegusbin = 0;
	private static byte g_radioflag_mpegcardin = 0;
	private static byte g_radioflag_bluelink = 0;
	private static byte g_radioflag_mpegipodin = 0;

	private void ProcessRadioFlag(int radioflag){
		if((radioflag&0x1)==0x1)
			g_radioflag_localmode = 1;
		else
			g_radioflag_localmode = 0;

		if((radioflag&0x2)==0x2)
			g_radioflag_stmode = 1;
		else
			g_radioflag_stmode = 0;

		if((radioflag&0x4)==0x4)
			g_radioflag_string = 1;
		else
			g_radioflag_string = 0;
		if((radioflag&0x8)==0x8)
			g_radioflag_rdsmode = 1;
		else
			g_radioflag_rdsmode = 0;
		if((radioflag&0x10)==0x10)
			g_radioflag_rdsta = 1;
		else
			g_radioflag_rdsta = 0;
		if((radioflag&0x20)==0x20)
			g_radioflag_rdstp = 1;
		else
			g_radioflag_rdstp = 0;
		if((radioflag&0x40)==0x40)
			g_radioflag_rdsaf = 1;
		else
			g_radioflag_rdsaf = 0;
		if((radioflag&0x80)==0x80)
			g_radioflag_rdseon = 1;
		else
			g_radioflag_rdseon = 0;
		if((radioflag&0x100)==0x100)
			g_radioflag_autoscan = 1;
		else
			g_radioflag_autoscan = 0;
		if((radioflag&0x200)==0x200)
			g_radioflag_intro = 1;
		else
			g_radioflag_intro = 0;
		if((radioflag&0x400)==0x400)
			g_radioflag_autoscanup = 1;
		else
			g_radioflag_autoscanup = 0;
		if((radioflag&0x800)==0x800)
			g_radioflag_mpegdiscin = 1;
		else
			g_radioflag_mpegdiscin = 0;
		if((radioflag&0x1000)==0x1000)
			g_radioflag_mpegusbin = 1;
		else
			g_radioflag_mpegusbin = 0;
		if((radioflag&0x2000)==0x2000)
			g_radioflag_mpegcardin = 1;
		else
			g_radioflag_mpegcardin = 0;
		if((radioflag&0x4000)==0x4000)
			g_radioflag_bluelink = 1;
		else
			g_radioflag_bluelink = 0;
		if((radioflag&0x8000)==0x8000)
			g_radioflag_mpegipodin = 1;
		else
			g_radioflag_mpegipodin = 0;
	}

	private static int g_sys_state = 0;
	public String str_rds_text = "";
	private static int g_radio_flag = 0;
	private static int g_radio_area = 0;
	private static int g_radio_curfreq = 0;
	private static int g_radio_locmode = 0;
	
	//开启MCU工作线程
	@Override
	protected void onResume() {
		super.onResume();

		if (null != gMCM){
			g_sys_state = gMCM.getSystemState();
			if(g_sys_state!=McuComSysState.CAR_MPEG_SYS_POWEROFF){
				str_rds_text = gMCM.getRdsMessage();

				if(g_sys_state != McuComSysState.CAR_MPEG_SYS_RADIO){
					g_sys_state = McuComSysState.CAR_MPEG_SYS_RADIO;
					gMCM.setSystemState(g_sys_state);
					byte[] data = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORTKEY, McuComKey.CAR_KEY_RADIO_SEL);
					send_command(McuComAddr.CAR_MPEG_KEY_ADR, data);
				}
				gMCM.changeAudioInput(3);
				gMCM.setMcuComClient();
				gMCM.setOnActionListener(mRadioAction);
				gMCM.setOnActionStringListener(mRadioStringAction);

				g_radio_flag = gMCM.getRadioFlag();
				ProcessRadioFlag(g_radio_flag);
				sendCommand(McuComAddr.CAR_MPEG_RADIO_FLAG_ADR,g_radio_flag);
				sendCommand(McuComAddr.CAR_MPEG_RADIO_RDS_PTY_ADR,g_radio_flag);
				g_radio_bandstate = gMCM.getRadioBandState();
				sendCommand(McuComAddr.CAR_MPEG_RADIO_BAND_ADR,g_radio_bandstate);
				g_radio_area = gMCM.getRadioArea();
				sendCommand(McuComAddr.CAR_MPEG_RADIO_AREA_ADR,g_radio_area);
				g_radio_curfreq = gMCM.getRadioCurFreq();
				sendCommand(McuComAddr.CAR_MPEG_RADIO_CUR_FREQ_ADR,g_radio_curfreq);
				for(int i = 0; i < 6; i++){
					g_radio_freqlist[i] = gMCM.getRadioFreqList(i);
					sendCommand(McuComAddr.CAR_MPEG_RADIO_FREQ_CH1_ADR+i,g_radio_freqlist[i]);
				}
				sendCommand(McuComAddr.CAR_MPEG_RADIO_FREQ_UPDATE_ADR,g_radio_bandstate);
				g_radio_stmode = gMCM.getRadioStMode();
				sendCommand(McuComAddr.CAR_MPEG_RADIO_ST_ADR,g_radio_stmode);
				g_radio_locmode = gMCM.getRadioLocMode();
				sendCommand(McuComAddr.CAR_MPEG_RADIO_LOC_ADR,g_radio_locmode);
	
			}
		}
		checkRds();
		Intent intent2 = new Intent();  
		intent2.setAction("com.android.launcher.showstate");
		intent2.putExtra("cur_state_off", 0);		
		sendBroadcast(intent2);
	}
	
	private int current;
	private static int g_radio_stmode = 0;
	private static int g_radio_bandstate = 0;
	
	//解析返回过来的数据
	private class RadioHandler extends Handler {
		@SuppressLint("ShowToast")
		public void handleMessage(Message msg) {
			switch (msg.what){
			case McuComAddr.CAR_MPEG_KEY_ADR:
				RadioPorcessKey(msg.arg1);
				break;
			case McuComAddr.CAR_MPEG_RADIO_FLAG_ADR:
//				if((g_radio_bandstate <= RADIO_BAND_FM3)&&(g_radioflag_autoscan == 0))
//				{
//					if(g_radioflag_stmode == 1)
//					{
//						if((g_radioflag_string == 1)&&(g_radioflag_autoscanup == 0))
//							qq.setBackgroundResource(R.drawable.qq_pressed);
//						else
//							qq.setBackgroundResource(R.drawable.qq_x);
//					}
//					else
//						qq.setBackgroundResource(R.drawable.qq_x);
//				}	
//				else
//					qq.setBackgroundResource(R.drawable.qq_x);
				break;
			case McuComAddr.CAR_MPEG_RADIO_BAND_ADR:
				break;
			case McuComAddr.CAR_MPEG_RADIO_AREA_ADR:
				switch (msg.arg1 & 0xff) {
				case 0:
					SEEKBAR_FROM=87.5f;
					SEEKBAR_TO = 108.0f;

					break;
				case 1:

					break;
				case 2:

					break;
				case 3:
					break;

				case 4:
					break;
				}
				//private final float SEEKBAR_FROM=87;
				//private final float SEEKBAR_TO = 108;

				//private final float AM_SEEKBAR_FROM=522;
				//private final float AM_SEEKBAR_TO = 1620;
				//system | local | FM freq  | step | AM freq | step |
				//---------------------------------------------------------
				//system0| EUROPE|87.5-108M | 50k  | 522-1620| 9k   |
				//system1| usa  |87.5-107.9| 200k | 530-1710| 10k  |
				//system2| USA2 |87.5-108M | 100k  | 530-1720| 10k   |
				//system3   波段1:    
				//| OIRT  | 65-74M   | 30k  | 522-1620| 9k   |
				//  波段2 -3:        
				//	| OIRT  | 87.5-108M   | 50k  | 522-1620| 9k   |  
				//system4| japan | 76-90M   | 100k | 522-1629| 9k   |
				//system5| M_EAST | 87.5-108M   | 100k | 531-1602| 9k   |
				//-------------------------------------------------------
				break;
			case McuComAddr.CAR_MPEG_RADIO_CUR_FREQ_ADR:
				current = msg.arg1;
				if(g_radio_bandstate <= RADIO_BAND_FM3){
					FMORAM = 1;
//					if(g_radio_stmode == 1)
//						st.setBackgroundResource(R.drawable.st_pressed);
//					else
//						st.setBackgroundResource(R.drawable.st_x);
//					if(g_radio_locmode == 1)
//						loc.setBackgroundResource(R.drawable.loc_pressed);
//					else
//						loc.setBackgroundResource(R.drawable.loc_x);
					//float a = (((float)msg.arg1) / 100);				
					cur_freq.setText("" + Format.format(((float)msg.arg1) / 100));
					//t.setText("" + (((float)msg.arg1) / 100));
					//t.setGravity(Gravity.CENTER);//内容居中
					hz.setText("MHz");
					Float progress = (Float.parseFloat(cur_freq.getText().toString()));
					main_seekbar_band.setProgress((int)((progress - SEEKBAR_FROM)/(SEEKBAR_TO-SEEKBAR_FROM) * SEEKBAR_MAX));//进度条
				}else{
					FMORAM = 2;
					//bandMin.setText("522");
					//bandMax.setText("1620");
//					loc.setBackgroundResource(R.drawable.loc_x);
//					st.setBackgroundResource(R.drawable.st_x);
//					qq.setBackgroundResource(R.drawable.qq_x);					
					cur_freq.setText("" + msg.arg1);
					//t.setGravity(Gravity.CENTER);((float)msg.arg1) / 100
					hz.setText("KHz");
					Float progress = (Float.parseFloat(cur_freq.getText().toString()));
					main_seekbar_band.setProgress((int)((progress - AM_SEEKBAR_FROM)/(AM_SEEKBAR_TO-AM_SEEKBAR_FROM) * SEEKBAR_MAX));//进度条
				}
				break;
			case McuComAddr.CAR_MPEG_RADIO_FREQ_CH1_ADR:
				setCHdata(MchOne,msg.arg1);
				break;
			case McuComAddr.CAR_MPEG_RADIO_FREQ_CH2_ADR:
				setCHdata(MchTwo,msg.arg1);
				break;
			case McuComAddr.CAR_MPEG_RADIO_FREQ_CH3_ADR:
				setCHdata(MchThree,msg.arg1);
				break;
			case McuComAddr.CAR_MPEG_RADIO_FREQ_CH4_ADR:
				setCHdata(MchFour,msg.arg1);
				break;
			case McuComAddr.CAR_MPEG_RADIO_FREQ_CH5_ADR:
				setCHdata(MchFive,msg.arg1);
				break;
			case McuComAddr.CAR_MPEG_RADIO_FREQ_CH6_ADR:
				setCHdata(MchSix,msg.arg1);
				// setCHdata(msg.what-McuComAddr.CAR_MPEG_RADIO_FREQ_CH1_ADR,msg.arg1);				
				break;
			case McuComAddr.CAR_MPEG_RADIO_FREQ_UPDATE_ADR:
				Items = -1;
				for(int i = 0; i < 6; i++)
				{
					if((g_radio_freqlist[i] & 0x8000) == 0x8000)
					{
						Items = i;
						Toast.makeText(MainActivity.this, "i==="+i,0).show();
						Toast.makeText(MainActivity.this, "g_radio_freqlist==="+g_radio_freqlist,0).show();
						break;
					}
				}

				if(msg.arg1 == RADIO_BAND_FM1){
					RarioUpdate(Items);
					Toast.makeText(MainActivity.this, "==FM1=="+Items,0).show();
					t_band.setText("FM1");
					//					adapter.setSeclection(Items);
					//					if(viewFlipper.getDisplayedChild() != 0) Animation(mode,0);
					//					adapter.notifyDataSetChanged();
				}else if(msg.arg1 == RADIO_BAND_FM2){
					//					if(Items != -1) Items += 6;
					//					adapter1.setSeclection(Items);
					//					if(viewFlipper.getDisplayedChild() != 1) Animation(mode,1);
					//					adapter1.notifyDataSetChanged();
					RarioUpdate(Items);
					Toast.makeText(MainActivity.this, "=FM2==="+Items,0).show();
					t_band.setText("FM2");
				}else if(msg.arg1 == RADIO_BAND_FM3){
					//					if(Items != -1) Items += 12;
					//					adapter2.setSeclection(Items);
					//					if(viewFlipper.getDisplayedChild() != 2) Animation(mode,2);
					//					adapter2.notifyDataSetChanged();
					RarioUpdate(Items);
					Toast.makeText(MainActivity.this, "=FM3==="+Items,0).show();
					t_band.setText("FM3");
				}else if(msg.arg1 == RADIO_BAND_AM1){
					//					adapter.setSeclection(Items);
					//					if(viewFlipper.getDisplayedChild() != 3) Animation(mode,3);
					//					adapter.notifyDataSetChanged();
					RarioUpdate(Items);
					t_band.setText("AM1");Toast.makeText(MainActivity.this, "FM4=Items==="+Items,0).show();
				}else if(msg.arg1 == RADIO_BAND_AM2){
					//					if(Items != -1) Items += 6;
					//					adapter1.setSeclection(Items);
					//					if(viewFlipper.getDisplayedChild() != 4) Animation(mode,4);
					//					adapter1.notifyDataSetChanged();
					RarioUpdate(Items);
					t_band.setText("AM2");Toast.makeText(MainActivity.this, "=FM5=Items==="+Items,0).show();
				}
				//mode = 1;
				break;
			case McuComAddr.CAR_MPEG_RADIO_ST_ADR:
//				if(msg.arg1 == 1)
//					st.setBackgroundResource(R.drawable.st_pressed);
//				else
//					st.setBackgroundResource(R.drawable.st_x);
				break;
			case McuComAddr.CAR_MPEG_RADIO_LOC_ADR:
//				if(msg.arg1 == 1)
//					loc.setBackgroundResource(R.drawable.loc_pressed);
//				else
//					loc.setBackgroundResource(R.drawable.loc_x);
				break;
			case McuComAddr.CAR_MPEG_RADIO_RDSMSG_ADR:
				Log.i(TAG, "CAR_MPEG_RADIO_RDSMSG_ADR:"+msg.arg1);

				break;
			case McuComAddr.CAR_MPEG_RADIO_RDS_PTY_ADR:	
//				if(bRds == true)
//				{
//					TextView rdsText = (TextView) findViewById(R.id.rds_text);
//					rdsText.setText(str_rds_text);
//					ta.setVisibility(View.VISIBLE);
//					tp.setVisibility(View.VISIBLE);
//					af.setVisibility(View.VISIBLE);
//
//					if(g_radioflag_rdsta == 1)	ta.setBackgroundResource(R.drawable.f_ta_0);
//					else	ta.setBackgroundResource(R.drawable.f_ta);
//
//					if(g_radioflag_rdstp == 1)	tp.setBackgroundResource(R.drawable.f_tp_0);
//					else	tp.setBackgroundResource(R.drawable.f_tp);
//
//					if(g_radioflag_rdsaf == 1)	af.setBackgroundResource(R.drawable.f_af_0);
//					else	af.setBackgroundResource(R.drawable.f_af);	
//				}else{
//
//					ta.setVisibility(View.GONE);
//					tp.setVisibility(View.GONE);
//					af.setVisibility(View.GONE);
//				}				
				break;
			default:
				break;
			}
		}
	}	

	private void setCHdata(TextView view ,int f){
		Log.i("TAG", "==f==="+f);
		if((int)(f & 0x7FFF) > 2000){
			view.setText((Format.format((float)(f & 0x7FFF) / 100))+"".replace(",", "."));
		}else{
			view.setText(((int)(f & 0x7FFF)+""));
		}
	}

	//拖动进度条//更新进度条显示的数据发送到SeekBarHandler
	private void ShowSeekBar() {
		main_seekbar_band.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				if (fromUser) {
					Message msg = new Message();
					msg.what = progress;
					SeekBarhandler.sendMessage(msg);
					RarioUpdate(5);
					Log.i("TAG", "===sb=="+msg);
				}
			}
		});
	}

	
	
	//接收Handler返回的数据,更新频道,显示进度条频率
	Handler SeekBarhandler = new Handler() {
		public void handleMessage(android.os.Message msg) {			
			int am = msg.what;
			if(FMORAM == 1){
				float b = (float)(87.5+(SEEKBAR_TO-SEEKBAR_FROM) / SEEKBAR_MAX * am);
				int saw = (int)(Math.round(b*100));
				if(saw%5<5 && saw%5 != 0)
				{
					saw = saw+(5-saw%5);
				}
				if(saw%5>5)
				{
					saw = saw+(10-saw%5);
				}
				float c = (float)saw/100;
				cur_freq.setText("" + Format.format(c));
				send_command(McuComAddr.CAR_MPEG_RADIO_CUR_FREQ_ADR, Saw_Data(saw));
				Log.i("TAG", "==cur_freq1==="+cur_freq);
			}else{
				float b = (float)(522+(AM_SEEKBAR_TO-AM_SEEKBAR_FROM) / SEEKBAR_MAX * am);
				int c = (int)(Math.round(b*10)/10);
				send_command(McuComAddr.CAR_MPEG_RADIO_CUR_FREQ_ADR, Saw_Data(c));
				cur_freq.setText(c+"");
				Log.i("TAG", "==cur_freq2==="+cur_freq);
			}
		}
	};

	public void send_command(int addr,byte[] data){
		if (null != gMCM)
			gMCM.sendMcuComMultiData(addr,data);
	}

	/*
	 * 静音
	private static final int STREAM_MASTER = -100;
	private AudioManager audioManager = null;
	private Boolean music_booleanMute;
	private ImageButton mute;//
	private boolean isMuted(int streamType) {
		if (audioManager == null) {
			audioManager = (AudioManager) MainActivity.this.getSystemService(Context.AUDIO_SERVICE);
		}
		if (streamType == STREAM_MASTER) {
			return audioManager.isMasterMute();
		}else {
			return audioManager.isStreamMute(streamType);
		}
	}

	Handler handler_animation = new Handler() {
		public void handleMessage(android.os.Message msg) {	
			music_booleanMute = isMuted(AudioManager.STREAM_MUSIC);
			if(mute != null)
			{
				//		      	  if(music_booleanMute == true)  mute.setBackgroundResource(R.drawable.button_mute);
				//		      	  else  mute.setBackgroundResource(R.drawable.button_voice);
			}
		}
	};
 */
	
	//发送item请求去Mcu
	public View.OnLongClickListener LongClick=new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			switch (v.getId()) {
			case R.id.layout_1:
				byte[] data1 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data1);
//				RarioUpdate(0);
				break;
			case R.id.layout_2:
				byte[] data2 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data2);
//				RarioUpdate(1);
				break;
			case R.id.layout_3:
				byte[] data3 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data3);
//				RarioUpdate(2);
				break;
			case R.id.layout_4:
				byte[] data4 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data4);
//				RarioUpdate(3);
				break;
			case R.id.layout_5:
				byte[] data5 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data5);
//				RarioUpdate(4);
				break;
			case R.id.layout_6:
				byte[] data6 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data6);
//				RarioUpdate(5);
				break;
			}
			return false;
		}
	};

	//发送item请求去Mcu
	public View.OnClickListener ItemClick=new OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.layout_1:
				byte[] data1 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data1);
				RarioUpdate(0);
				Log.i("TAG", "===rl1=="+v);
				break;
			case R.id.layout_2:
				byte[] data2 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data2);
				RarioUpdate(1);
				Log.i("TAG", "===rl2=="+v);
				break;
			case R.id.layout_3:
				byte[] data3 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data3);
				RarioUpdate(2);
				Log.i("TAG", "===rl3=="+v);
				break;
			case R.id.layout_4:
				byte[] data4 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data4);
				RarioUpdate(3);
				Log.i("TAG", "===rl4=="+v);
				break;
			case R.id.layout_5:
				byte[] data5 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data5);
				RarioUpdate(4);
				Log.i("TAG", "===rl5=="+v);
				break;
			case R.id.layout_6:
				byte[] data6 = McuComKey.getKeyData(McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY,	McuComKey.CAR_KEY_NUM1);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data6);
				RarioUpdate(5);
				Log.i("TAG", "===rl6=="+v);
				break;
			}
		}
	};

	//发送item请求去Mcu
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.up:
			byte[] data_up = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY, McuComKey.CAR_KEY_SEEK_UP);
			send_command(McuComAddr.CAR_MPEG_KEY_ADR, data_up);
			break;
		case R.id.down:
			byte[] data_down = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY, McuComKey.CAR_KEY_SEEK_DN);
			send_command(McuComAddr.CAR_MPEG_KEY_ADR, data_down);
			break;
		case R.id.prev:
			byte[] data3 = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY, McuComKey.CAR_KEY_SEEK_UP);
			send_command(McuComAddr.CAR_MPEG_KEY_ADR, data3);
			break;
		case R.id.search:
			byte[] data6 = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.LONGKEY, McuComKey.CAR_KEY_AUTO_SCAN);
			send_command(McuComAddr.CAR_MPEG_KEY_ADR, data6);
			break;
		case R.id.band:
			if(ButtonPressed)
			{
				byte[] data1 = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORTKEY, McuComKey.CAR_KEY_BAND);
				send_command(McuComAddr.CAR_MPEG_KEY_ADR, data1);
				ButtonPressed = false;
				mButtonTimer = new Timer();
				TimerTask buttonTimertask1 = new TimerTask() {
					public void run() {
						ButtonPressed = true;
						if(mButtonTimer != null){
							mButtonTimer.cancel();
							mButtonTimer = null;
						}
					}
				};
				mButtonTimer.schedule(buttonTimertask1, 800);
			}
			break;
		case R.id.next:
			byte[] data2 = McuComKey.getKeyData( McuComKey.CAR_KEY_ATTR_TOUCH, McuComKey.SHORT_RELEASEKEY, McuComKey.CAR_KEY_SEEK_DN);
			send_command(McuComAddr.CAR_MPEG_KEY_ADR, data2);
			break;
		}
	}
	
	//获取返回来的item值更新rl
	private void RarioUpdate(int items) {
		clearSelection(items);
		if(items == -1) return;	
		switch (items) {
		case 0:
			Log.i("TAG", "===items0=="+items);
			back1.setVisibility(View.VISIBLE);
			MchOne.setTextColor(getResources().getColor(R.color.yellow));
			b_p1.setVisibility(View.INVISIBLE);//隐藏
			MpinpuOne.setVisibility(View.VISIBLE);//显示
			anim1.start();
			break;
		case 1:
			Log.i("TAG", "===items1=="+items);
			back2.setVisibility(View.VISIBLE);
			MchTwo.setTextColor(getResources().getColor(R.color.yellow));
			b_p2.setVisibility(View.INVISIBLE);
			MpinpuTwo.setVisibility(View.VISIBLE);
			anim2.start();
			break;
		case 2:
			back3.setVisibility(View.VISIBLE);
			MchThree.setTextColor(getResources().getColor(R.color.yellow));
			b_p3.setVisibility(View.INVISIBLE);
			MpinpuThree.setVisibility(View.VISIBLE);
			anim3.start();			Log.i("TAG", "===items2=="+items);
			break;
		case 3:
			back4.setVisibility(View.VISIBLE);
			MchFour.setTextColor(getResources().getColor(R.color.yellow));
			b_p4.setVisibility(View.INVISIBLE);
			MpinpuFour.setVisibility(View.VISIBLE);
			anim4.start();			Log.i("TAG", "===items3=="+items);
			break;
		case 4:
			back5.setVisibility(View.VISIBLE);
			MchFive.setTextColor(getResources().getColor(R.color.yellow));
			b_p5.setVisibility(View.INVISIBLE);
			MpinpuFive.setVisibility(View.VISIBLE);
			anim5.start();			Log.i("TAG", "===items4=="+items);
			break;
		case 5:
			back6.setVisibility(View.VISIBLE);
			MchSix.setTextColor(getResources().getColor(R.color.yellow));
			b_p6.setVisibility(View.INVISIBLE);
			MpinpuSix.setVisibility(View.VISIBLE);
			anim6.start();			
			Log.i("TAG", "===items5=="+items);
			break;
		default:
			break;
		}
	}
	private void clearSelection(int item) {
		if(item != 0){
			Log.i("TAG", "=====item0======"+item);
			back1.setVisibility(View.INVISIBLE);
			MchOne.setTextColor(Color.WHITE);
			b_p1.setVisibility(View.VISIBLE);
			MpinpuOne.setVisibility(View.INVISIBLE);
			anim1.stop();
		}
		if(item != 1){	
			Log.i("TAG", "=====item1======"+item);
			back2.setVisibility(View.INVISIBLE);
			MchTwo.setTextColor(Color.WHITE);
			b_p2.setVisibility(View.VISIBLE);
			MpinpuTwo.setVisibility(View.INVISIBLE);
			anim2.stop();
		}
		if(item != 2){
			Log.i("TAG", "======item2====="+item);
			back3.setVisibility(View.INVISIBLE);
			MchThree.setTextColor(Color.WHITE);
			b_p3.setVisibility(View.VISIBLE);
			MpinpuThree.setVisibility(View.INVISIBLE);
			anim3.stop();
		}
		if(item != 3){
			Log.i("TAG", "=====item3======"+item);

			back4.setVisibility(View.INVISIBLE);
			MchFour.setTextColor(Color.WHITE);
			b_p4.setVisibility(View.VISIBLE);
			MpinpuFour.setVisibility(View.INVISIBLE);
			anim4.stop();
		}
		if(item != 4){
			Log.i("TAG", "======item4====="+item);
			back5.setVisibility(View.INVISIBLE);
			MchFive.setTextColor(Color.WHITE);
			anim5.stop();
			b_p5.setVisibility(View.VISIBLE);
			MpinpuFive.setVisibility(View.INVISIBLE);
		}
		if(item != 5){
			back6.setVisibility(View.INVISIBLE);
			Log.i("TAG", "======item5====="+item);
			MchSix.setTextColor(Color.WHITE);
			anim6.stop();
			b_p6.setVisibility(View.VISIBLE);
			MpinpuSix.setVisibility(View.INVISIBLE);
		}
	}


	private void RadioPorcessKey(int keydata)
	{
		switch(keydata)
		{
		case McuComKey.CAR_KEY_MENU_EXIT:
			Log.i(TAG, "=====CAR_KEY_MENU_EXIT====");
			/*
				if(gMCM!=null)
				g_sys_state = gMCM.getSystemState();
				if(g_sys_state!=McuComSysState.CAR_MPEG_SYS_POWEROFF)
			 */
			finish();
			break;
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_BACK)
		{
			if (null != gMCM)
			{
				if(gMCM.getSystemState()==g_sys_state)
				{
					gMCM.releaseAudioInput();
				}
			}
			Intent intent2 = new Intent();  
			intent2.setAction("com.android.launcher.showstate");
			intent2.putExtra("cur_state_off", 1);		
			sendBroadcast(intent2);  
		}
		return super.onKeyDown(keyCode, event);
	}

	private Thread animation = null;
	@Override
	protected void onDestroy() {
		Log.i(TAG, "=====onDestroy====");
		animation.interrupt();
		animation = null;

		Intent intent2 = new Intent();  
		intent2.setAction("com.android.launcher.showstate");
		intent2.putExtra("cur_state_off", 1);		
		sendBroadcast(intent2);

		mRadioHandler.removeCallbacksAndMessages(null);
		SeekBarhandler.removeCallbacksAndMessages(null);

		super.onDestroy();
	}
}

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/adorn"
    tools:context="com.example.textradio.MainActivity" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="218.8dp"
        android:background="@drawable/band_back"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/cur_freq"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="@string/freqtext"
            android:textColor="#ffffff"
            android:textSize="92sp" />

        <ImageButton
            android:id="@+id/up"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="15dp"
            android:background="@drawable/up" />

        <ImageButton
            android:id="@+id/down"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="15dp"
            android:background="@drawable/down" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/cur_freq"
            android:layout_centerHorizontal="true"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/t_band"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginRight="20dp"
                android:layout_weight="1"
                android:text="@string/bandtext"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#FFFFFFFF"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/hz"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:text="@string/freqmhz"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#FFFFFFFF"
                android:textSize="12sp" />
        </LinearLayout>

        <SeekBar
            android:id="@+id/main_seekbar_band"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_marginBottom="6dp"
            android:background="@drawable/main_seekbar_band"
            android:progressDrawable="@drawable/scrubber_progress_horizontal_holo_light"
            android:thumb="@drawable/scrubber_control_selector_holo"
            android:thumbOffset="24px" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="218.8dp"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/ch_back" >

            <RelativeLayout
                android:id="@+id/layout_1"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1" >
                <TextView
                    android:id="@+id/ch_one"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="75dp"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:textColor="#ffffff"
                    android:textSize="22sp"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/pinpu_one"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/zhuzhen"
                    android:visibility="gone" />

                <ImageView
                    android:id="@+id/ch_back1"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/ch_back2"
                    android:visibility="gone" />

                <ImageView
                    android:id="@+id/b_p1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/p1" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/layout_2"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/ch_back2"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/ch_back2"
                    android:visibility="gone" />

                <ImageView
                    android:id="@+id/pinpu_two"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/zhuzhen" 
                    android:visibility="gone"/>

                <TextView
                    android:id="@+id/ch_two"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="75dp"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:textColor="#ffffff"
                    android:textSize="22sp"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/b_p2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/p2" />
            </RelativeLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/ch_back" >

            <RelativeLayout
                android:id="@+id/layout_3"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/ch_back3"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/ch_back2"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/ch_three"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="75dp"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:textColor="#ffffff"
                    android:textSize="22sp"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/pinpu_three"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:visibility="gone"
                    android:background="@drawable/zhuzhen" />

                <ImageView
                    android:id="@+id/b_p3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/p3" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/layout_4"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/ch_back4"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/ch_back2"
                    android:visibility="gone" />

                <ImageView
                    android:id="@+id/pinpu_four"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:visibility="gone"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/zhuzhen" />

                <ImageView
                    android:id="@+id/b_p4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/p4" />

                <TextView
                    android:id="@+id/ch_four"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="75dp"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:textColor="#ffffff"
                    android:textSize="22sp"
                    android:textStyle="bold" />
            </RelativeLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/ch_back" >

            <RelativeLayout
                android:id="@+id/layout_5"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/ch_back5"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/ch_back2"
                    android:visibility="gone"
                     />

                <TextView
                    android:id="@+id/ch_five"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="75dp"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:textColor="#ffffff"
                    android:textSize="22sp"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/pinpu_five"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:visibility="gone"
                    android:background="@drawable/zhuzhen" />

                <ImageView
                    android:id="@+id/b_p5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/p5" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/layout_6"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/ch_back6"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/ch_back2"
                    android:visibility="gone" />

                <ImageView
                    android:id="@+id/pinpu_six"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:visibility="gone"
                    android:background="@drawable/zhuzhen" />

                <ImageView
                    android:id="@+id/b_p6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:background="@drawable/p6" />

                <TextView
                    android:id="@+id/ch_six"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="75dp"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:textColor="#ffffff"
                    android:textSize="22sp"
                    android:textStyle="bold" />
            </RelativeLayout>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@drawable/button_back"
        android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/prev"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/left" />

        <ImageButton
            android:id="@+id/search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/sousuo" />

        <ImageButton
            android:id="@+id/band"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/band" />

        <ImageButton
            android:id="@+id/next"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/right" />
    </LinearLayout>

</FrameLayout>


你可能感兴趣的:(mcu,Radio,收音机)