TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
R.styleable.LovelyView, 0, 0);
try {
// get the text and colors specified using the names in attrs.xml
leftLabel = a.getString(R.styleable.LovelyView_leftLabel);
rightLabel = a.getString(R.styleable.LovelyView_rightLabel);
leftStyle = a.getResourceId(R.styleable.LovelyView_leftLabelStyle, android.R.style.TextAppearance_DeviceDefault);
rightStyle = a.getResourceId(R.styleable.LovelyView_rightLabelStyle, android.R.style.TextAppearance_DeviceDefault);
} finally {
a.recycle();
}
LayoutInflater.from(context).inflate(R.layout.key_value_layout, this);
//left text view
leftTextView = (TextView) this.findViewById(R.id.leftTextView);
leftTextView.setText(leftLabel);
leftTextView.setTextAppearance(context, leftStyle);
//right text view
rightTextView = (TextView) this.findViewById(R.id.rightTextView);
rightTextView.setText(rightLabel);
rightTextView.setTextAppearance(context, rightStyle);