WEB开发网
开发学院手机开发Android 开发 android控件自定义TabHost 阅读

android控件自定义TabHost

 2012-10-12 11:15:56 来源:WEB开发网   
核心提示:super.onSizeChanged(w, h, oldw, oldh); if (mListener != null) { mListener.OnResize(w, h, oldw, oldh); } } @Override protected void onLayout(boolean chang
super.onSizeChanged(w, h, oldw, oldh);
if (mListener != null) {
mListener.OnResize(w, h, oldw, oldh);
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

}

具体的使用
/**
* 初始化底部按钮
*/
private void initRadios() {
RadioButton button0 = ((RadioButton) findViewById(Lthjlink
.getIdxct_lthj_radio_button0()));
button0.setText(Lthjlink.getStringxct_lthj_tab_buy());
button0.setOnCheckedChangeListener(new myonCheckedChanged());
RadioButton button1 = ((RadioButton) findViewById(Lthjlink
.getIdxct_lthj_radio_button1()));
button1.setText(Lthjlink.getStringxct_lthj_tab_sell());
button1.setOnCheckedChangeListener(new myonCheckedChanged());
RadioButton button2 = ((RadioButton) findViewById(Lthjlink
.getIdxct_lthj_radio_button2()));
button2.setText(Lthjlink.getStringxct_lthj_tab_entrust());
button2.setOnCheckedChangeListener(new myonCheckedChanged());
}
private void setupIntent() {
tabHost = getTabHost();
LayoutInflater.from(this).inflate(
Lthjlink.getLayoutxct_lthj_newtradebuy_portrait(),
tabHost.getTabContentView(), true);
// mHost.setBackgroundResource(R.drawable.upomp_lthj_bg_main);
tabHost.addTab(buildTabSpec("buytag",
Lthjlink.getStringxct_lthj_tab_buy(),
Lthjlink.getDrawablexct_lthj_frmtopback(),
Lthjlink.getIdxct_lthj_tab1()));
tabHost.addTab(buildTabSpec("selltag",
Lthjlink.getStringxct_lthj_tab_sell(),
Lthjlink.getDrawablexct_lthj_frmtopback(), this.sellActivity));
tabHost.addTab(buildTabSpec("chedantag",
Lthjlink.getStringxct_lthj_tab_entrust(),
Lthjlink.getDrawablexct_lthj_frmtopback(), this.entrustActivity));
}
private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon,
final Intent content) {
return tabHost
.newTabSpec(tag)
.setIndicator(getString(resLabel),
getResources().getDrawable(resIcon))
.setContent(content);
}
private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon,
final int content) {
return tabHost
.newTabSpec(tag)
.setIndicator(getString(resLabel),
getResources().getDrawable(resIcon))
.setContent(content);
}


/**
* 切换模块
*/
public class myonCheckedChanged implements
android.widget.CompoundButton.OnCheckedChangeListener {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
//模块切换,
}
}
}

上一页  1 2 3 4 

Tags:android 控件 定义

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接