package com.example.mountaintravel.view;


import com.smart.gtstrvl.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


public class TitleBarView extends LinearLayout {
	ImageView leftIcon;
	ImageView rightIcon;
	TextView titleText;

	public TitleBarView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		inflate(context, R.layout.layout_titlebar, this);
		if (isInEditMode()) {
			return;
		}
		leftIcon = (ImageView) findViewById(R.id.left_icon);
		rightIcon = (ImageView) findViewById(R.id.right_icon);
		titleText = (TextView) findViewById(R.id.titleText);
	}

	public void initTitleBar(int leftIconId, int rightIconId, String text,
			View.OnClickListener l) {
		titleText.setText(text);
		if (leftIconId == -1) {
			leftIcon.setVisibility(View.INVISIBLE);
		} else {
			leftIcon.setImageResource(leftIconId);
			leftIcon.setOnClickListener(l);
		}
		if (rightIconId == -1) {
			rightIcon.setVisibility(View.INVISIBLE);
		} else {
			rightIcon.setImageResource(rightIconId);
			rightIcon.setOnClickListener(l);
		}

	}
}
