首页 > 其他 > 详细

组合组件

时间:2014-05-22 01:56:13      阅读:347      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
package com.example.ceshi;

import android.app.Activity;
import android.content.Context;
import android.opengl.Visibility;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

public class TitleView extends FrameLayout {
    private View _view;
    private Button _back;
    private Button _right;
    private TextView _title;
    public TitleView(Context context, AttributeSet attrs) {
        super(context, attrs);
        _view = LayoutInflater.from(context).inflate(R.layout.title, this);        
        _back = (Button)_view.findViewById(R.id.back);
        
        _right = (Button)_view.findViewById(R.id.right);
        _title = (TextView)_view.findViewById(R.id.title);
        
        _back.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                ((Activity)getContext()).finish();
            }
        });
        
    }
    
    public void setLeftButtonText(String str){
        _back.setText(str);
    }

    public void setTitleText(String str){
        _title.setText(str);
    }
    
    public void setRightButton(Boolean bool){
        bool = bool ? true:false;
        if(bool){
            _right.setVisibility(VISIBLE);
        }else{
            _right.setVisibility(GONE);
        }
        
    }
    
    public void setRightOnclick(OnClickListener onClickListener){
        _right.setOnClickListener(onClickListener);
    }
}
bubuko.com,布布扣

 

组合组件,布布扣,bubuko.com

组合组件

原文:http://www.cnblogs.com/lihaolihao/p/3738718.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!