Я сделал следующее
1) Создание стиля
2) определение пользовательского макета представления
3) Создание требуемого класса
public class Viewee extends LinearLayout
{
public Viewee(Context context, AttributeSet attributeSet)
{
super(context, attributeSet);
View.inflate(context, R.layout.viewee, this);
TextView textView = (TextView) findViewById(R.id.custom_text);
TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.Viewee);
int id = typedArray.getResourceId(R.styleable.Viewee_linkedView, 0);
if (id != 0)
{
View view = findViewById(id);
textView.setText(((TextView) view).getText().toString());
}
typedArray.recycle();
}
}
] и, наконец, в действии, как показано ниже
теперь, хотя я получаю ненулевой id
в конструкторе Viewee, findViewById(id)
возвращает ноль и NullPointerException
происходит .
что я упускаю?