android 备忘

public void initToolBar(int index) {
		newsLayout = (RelativeLayout) findViewById(R.id.news);
		wbLayout = (RelativeLayout) findViewById(R.id.wb);
		galleryLayout = (RelativeLayout) findViewById(R.id.gallery);
		videoLayout = (RelativeLayout) findViewById(R.id.video);
		moreLayout = (RelativeLayout) findViewById(R.id.more);

		news = (ImageView) findViewById(R.id.index_news);
		wb = (ImageView) findViewById(R.id.index_wb);
		gallery = (ImageView) findViewById(R.id.index_gallery);
		video = (ImageView) findViewById(R.id.index_video);
		more = (ImageView) findViewById(R.id.index_more);

		news_label = (TextView) findViewById(R.id.index_news_label);
		wb_label = (TextView) findViewById(R.id.index_wb_label);
		video_label = (TextView) findViewById(R.id.index_video_label);
		more_label = (TextView) findViewById(R.id.index_more_label);
		gallery_label = (TextView) findViewById(R.id.index_gallery_label);

		newsLayout.setOnClickListener(click);
		wbLayout.setOnClickListener(click);
		galleryLayout.setOnClickListener(click);
		videoLayout.setOnClickListener(click);
		moreLayout.setOnClickListener(click);

		switch (index) {
		case 0:
			news.setImageResource(R.drawable.tab_news_current);
			newsLayout.setBackgroundResource(R.drawable.tab_background_current);
			news_label.setTextColor(Color.WHITE);
			break;
		case 1:
			wb.setImageResource(R.drawable.tab_wb_current);
			wbLayout.setBackgroundResource(R.drawable.tab_background_current);
			wb_label.setTextColor(Color.WHITE);
			break;
		case 2:
			gallery.setImageResource(R.drawable.tab_gallery_current);
			galleryLayout
					.setBackgroundResource(R.drawable.tab_background_current);
			gallery_label.setTextColor(Color.WHITE);
			break;
		case 3:
			video.setImageResource(R.drawable.tab_video_current);
			videoLayout
					.setBackgroundResource(R.drawable.tab_background_current);
			video_label.setTextColor(Color.WHITE);
			break;
		case 4:
			more.setImageResource(R.drawable.tab_more_current);
			moreLayout.setBackgroundResource(R.drawable.tab_background_current);
			more_label.setTextColor(Color.WHITE);
			break;
		}

	}

  

posted @ 2013-01-02 15:39  jason-lee  阅读(101)  评论(0)    收藏  举报