/******************************************************************************* * Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package fr.gotorennes.view; import android.content.Context; import android.graphics.Bitmap; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import fr.gotorennes.R; public class TitleBar extends RelativeLayout { public static final int ID = 0x1f080002; private ImageView icon; private TextView title; private TextView subtitle; public TitleBar(Context context) { this(context, null); } public TitleBar(Context context, AttributeSet attrs) { this(context, attrs, 0); } public TitleBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setId(ID); setBackgroundResource(R.drawable.titlebar); LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vi.inflate(R.layout.title_bar, this); icon = (ImageView) findViewById(R.id.icon); title = (TextView) findViewById(R.id.title); subtitle = (TextView) findViewById(R.id.subtitle); } public void setIcon(int resId) { this.icon.setImageResource(resId); } public void setIcon(Bitmap icon) { this.icon.setImageBitmap(icon); } public void setTitle(int resId) { this.title.setText(resId); } public void setTitle(String title) { this.title.setText(title); } public void setSubtitle(int resId) { this.subtitle.setText(resId); this.subtitle.setVisibility(View.VISIBLE); } public void setSubtitle(String subtitle) { this.subtitle.setText(subtitle); this.subtitle.setVisibility(View.VISIBLE); } }