super(context, attrs);
setOrientation(VERTICAL);
View view = LayoutInflater.from(context).inflate(R.layout.address, this);
mNameView = (TextView) view.findViewById(R.id.name);
mStreetView = (TextView) view.findViewById(R.id.street);
mCityStateZipView = (TextView) view.findViewById(R.id.cityStateZip);
mCountryView = (TextView) view.findViewById(R.id.country);
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.AddressView,
0, 0);
try {
mNameView.setText(a.getString(R.styleable.AddressView_name));
int streetNumber = a.getInteger(R.styleable.AddressView_streetNumber, -1);
mStreetView.setText((streetNumber <= 0 ? "" : Integer.toString(streetNumber)) +
" " + a.getString(R.styleable.AddressView_streetName));
mCityStateZipView.setText(a.getString(R.styleable.AddressView_city) + ", " +
a.getString(R.styleable.AddressView_state) + " " +
a.getString(R.styleable.AddressView_zip));
mCountryView.setText(a.getString(R.styleable.AddressView_country));
} finally {
a.recycle();
}