亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

求解決為什么為這樣

public class bar extends RelativeLayout {
? ?private Button leftButton,rightButton;
? ?private TextView tvTitle;

? ?private ?int leftTextColor;
? ?private Drawable leftBackground;
? ?private String leftText;

? ?private ?int rightTextColor;
? ?private Drawable rightBackground;
? ?private String rightText;

? ?private ?int titleTextColor;
? ?private float titleTextSize;
? ?private String titleText;



? ?public bar(Context context, AttributeSet attrs) {
? ? ? ?super(context, attrs);
? ? ? ?TypedArray ta= context.obtainStyledAttributes(attrs,R.styleable.Topbar);
? ? ? ?leftTextColor=ta.getColor(R.styleable.Topbar_leftTextColor, 0);
? ? ? ?leftBackground=ta.getDrawable(R.styleable.Topbar_leftBackground);
? ? ? ?leftText=ta.getString(R.styleable.Topbar_leftText);

? ? ? ?rightTextColor=ta.getColor(R.styleable.Topbar_rightTextColor, 0);
? ? ? ?rightBackground=ta.getDrawable(R.styleable.Topbar_rightBackground);
? ? ? ?rightText=ta.getString(R.styleable.Topbar_rightText);

? ? ? ?titleTextColor=ta.getColor(R.styleable.Topbar_titleTextColor, 0);
? ? ? ?titleTextSize=ta.getDimension(R.styleable.Topbar_titileTextSize, 0);
? ? ? ?titleText=ta.getString(R.styleable.Topbar_title);

? ? ? ?ta.recycle();

? ? ? ?leftButton=new Button(context);
? ? ? ?rightButton=new Button(context);
? ? ? ?tvTitle=new TextView(context);

? ? ? ?leftButton.setTextColor(leftTextColor);
? ? ? ?leftButton.setBackground(leftBackground);
? ? ? ?leftButton.setText(leftText);

? ? ? ?rightButton.setTextColor(rightTextColor);
? ? ? ?rightButton.setBackground(rightBackground);
? ? ? ?rightButton.setText(rightText);

? ? ? ?tvTitle.setText(titleText);
? ? ? ?tvTitle.setTextColor(titleTextColor);
? ? ? ?tvTitle.setTextSize(titleTextSize);
? ?}
}


加粗有下劃線的位置 android studio 會變紅色波浪線 報錯。

http://img1.sycdn.imooc.com//55a37eaa0001ee5b15200655.jpg

錯誤代碼提示如下:

http://img1.sycdn.imooc.com//55a37ef0000136ae13830406.jpg

最低版本選的是4.0


正在回答

1 回答

按ALT加ENTER會有提示的

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android UI模板設計
  • 參與學習       76032    人
  • 解答問題       233    個

快來學習如何在Android中自定義View,本次課程一定會讓你獲益匪淺

進入課程

求解決為什么為這樣

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號