Back to project page SimpleReader.
The source code is released under:
Apache License
If you think the Android project SimpleReader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dreamteam.app.ui; /* w w w . j av a2s .c om*/ import com.dreamteam.app.utils.Logger; import com.dreateam.app.ui.R; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.RelativeLayout.LayoutParams; /** * A activity with title bar * notice use setView instead of setContentView * @author chourentang */ public abstract class BaseTitledActivity extends BaseActivity { private LinearLayout contentView; private ImageButton mLeftButton; private ImageButton mRightButton; private TextView mCenterTitle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initView(); } @Override public void setContentView(int layoutResID) { new Exception("Activity extends from BaseTitledActivity cannot use setContentView, use setView instead.") .printStackTrace(); } private void initView() { super.setContentView(R.layout.activity_base_titled); contentView = (LinearLayout)findViewById(R.id.contentView); mLeftButton = (ImageButton) findViewById(R.id.common_left_button); mRightButton = (ImageButton) findViewById(R.id.common_right_button); mCenterTitle = (TextView) findViewById(R.id.common_center_text); } protected void setView(int resId) { if(resId == -1) { Logger.error("error", "the resId is invalide."); return; } View view = ((LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(resId, null); LayoutParams lp = (LayoutParams) view.getLayoutParams(); if (lp == null) lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); lp.width = LayoutParams.FILL_PARENT; lp.height = LayoutParams.FILL_PARENT; view.setLayoutParams(lp); contentView.addView(view); } protected void setTitleText(int strId) { if(strId == -1) { Logger.error("error", "the resId is invalide."); return; } mCenterTitle.setText(strId); } protected void setLeftButtonListener(OnClickListener listener) { mLeftButton.setOnClickListener(listener); } protected BaseTitledActivity setRightButtonBackground(int resId) { mRightButton.setBackgroundResource(resId); return this; } protected void setRightButtonListener(OnClickListener listener) { mRightButton.setOnClickListener(listener); } protected void hideRightButton() { if(mRightButton.getVisibility() == View.VISIBLE) { mRightButton.setVisibility(View.INVISIBLE); } } }