Код: Выделить всё
public class Group extends LinearLayout {
private TextView headerTextView;
public Group(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs,
R.styleable.Group, 0, 0);
String string = typedArray.getString(R.styleable.Group_headerText);
typedArray.recycle();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.widget_group, this, true);
headerTextView = (TextView) v.findViewById(R.id.header_text);
headerTextView.setText(string);
}
}
Я нашел какое-то решение с надуванием, но я действительно не хочу его использовать; это неправильный способ создания объекта.
Мне нужен пример того, как эта область
Код: Выделить всё
Group g = new Group(v.getContext(),arrt);
Подробнее здесь: https://stackoverflow.com/questions/189 ... mmatically
Мобильная версия