第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

自定義控件

自定義控件

慕粉4089507 2017-06-17 16:37:09
幫忙看下錯(cuò)在哪public?class?Topbar?extends?RelativeLayout{ ????private?Button?rightButton; ????private?TextView?tvTitle; ????private?Button?leftButton; ????private?int?textColor; ????private?String?titleText; ????private?float?titleTextSize; ????private?Drawable?titleBackground; ????private?int?leftTextColor; ????private?String?leftText; ????private?float?leftTextSize; ????private?Drawable?leftBackground; ????private?int?rightTextColor; ????private?String?rightText; ????private?float?rightTextSize; ????private?Drawable?rightBackground; ????public?Topbar(Context?context,?AttributeSet?attrs)?{ ????????super(context,?attrs); ????????TypedArray?ta?=?context.obtainStyledAttributes(attrs,?R ????????????????.styleable.Topbar); ????????leftBackground?=?ta.getDrawable(R.styleable.Topbar_leftTextBackgroung); ????????leftText?=?ta.getString(R.styleable.Topbar_leftText); ????????leftTextSize?=?ta.getFloat(R.styleable.Topbar_leftTextSize,?0); ????????leftTextColor?=?ta.getColor(R.styleable.Topbar_leftTextColor,?0); ????????rightBackground?=?ta.getDrawable(R.styleable.Topbar_rightTextBackgroung); ????????rightTextSize?=?ta.getFloat(R.styleable.Topbar_rightTextSize,?0); ????????rightText?=?ta.getString(R.styleable.Topbar_rightText); ????????rightTextColor?=?ta.getColor(R.styleable.Topbar_rightTextColor,?0); ????????titleTextSize?=?ta.getFloat(R.styleable.Topbar_titleTextSize,?0); ????????titleText?=?ta.getString(R.styleable.Topbar_title); ????????textColor?=?ta.getColor(R.styleable.Topbar_titleTextColor,?0); ????????titleBackground?=?ta.getDrawable(R.styleable.Topbar_titleBackground); ????????ta.recycle(); ????????leftButton?=?new?Button(context); ????????rightButton?=?new?Button(context); ????????tvTitle?=?new?TextView(context); ????????leftButton.setText(leftText); ????????leftButton.setTextSize(leftTextSize); ????????leftButton.setBackground(leftBackground); ????????leftButton.setTextColor(leftTextColor); ????????rightButton.setText(rightText); ????????rightButton.setTextSize(rightTextSize); ????????rightButton.setBackground(rightBackground); ????????rightButton.setTextColor(rightTextColor); ????????tvTitle.setText(titleText); ????????tvTitle.setTextSize(titleTextSize); ????????tvTitle.setTextColor(textColor); ????????tvTitle.setBackground(titleBackground); ????????tvTitle.setGravity(Gravity.CENTER); ????????setBackgroundColor(0x008000); ????????LayoutParams?leftParams?=?new?LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ????????????????LayoutParams.WRAP_CONTENT); ????????leftParams.addRule(RelativeLayout.ALIGN_LEFT,?TRUE); ????????addView(leftButton,?leftParams); ????????LayoutParams?rightParams?=?new?LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ????????????????LayoutParams.WRAP_CONTENT); ????????rightParams.addRule(RelativeLayout.ALIGN_RIGHT,?TRUE); ????????addView(rightButton,?rightParams); ????????LayoutParams?titleParams?=?new?LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ????????????????LayoutParams.MATCH_PARENT); ????????titleParams.addRule(RelativeLayout.CENTER_IN_PARENT,?TRUE); ????????addView(tvTitle,?titleParams); ????} }
查看完整描述

1 回答

?
ewang1986

TA貢獻(xiàn)27條經(jīng)驗(yàn) 獲得超5個(gè)贊

要把報(bào)錯(cuò)信息貼出來哦

查看完整回答
反對(duì) 回復(fù) 2017-06-20
  • 1 回答
  • 0 關(guān)注
  • 916 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)