String message = attr.getAttributeValue(null, "message");値の取得は、「getAttributeValue」や「getAttributeIntValue」で行っています。これらは、第1引数にパッケージ名、第2引数に属性名(getAttributeIntValueでは第3引数にデフォルトの値)をそれぞれ指定して呼び出します。例えば、getAttributeValue(null, "message")ならば"message"という属性のString値を取り出しますし、getAttributeIntValue(null, "drawColor", Color.RED)ならば"drawColor"という属性のint値を取得します。
this.message = message != null ? message : this.message;
this.messageSize = attr.getAttributeIntValue(null, "messageSize", 10);
this.drawColor = attr.getAttributeIntValue(null, "drawColor", Color.RED);
this.messageColor = attr.getAttributeIntValue(null, "messageColor", Color.BLUE);
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
public MySimpleView(Context context,
AttributeSet attr) {
super(context, attr);
String message = attr.getAttributeValue
(null, "message");
this.message = message != null ? message :
this.message;
this.messageSize = attr.getAttributeIntValue
(null, "messageSize", 10);
this.drawColor = attr.getAttributeIntValue
(null, "drawColor", Color.RED);
this.messageColor = attr.getAttributeIntValue
(null, "messageColor", Color.BLUE);
}
| << 前へ | 次へ >> |