我可能犯了一些愚蠢的错误。
我有一个自定义视图并使用 LayoutInflater 从 XML 获取布局。现在,假设我有一个名为 bt1 的按钮。通常,我会使用 findViewById ,但这不起作用。
如何在该自定义视图中获取按钮?
LinearLayout lytContainer;
public obj(Context c){
super(c);
lytContainer = (LinearLayout) View.inflate(
this.getContext(), R.layout.myLayout, null);
TextView t = (TextView)findViewById(R.id.bt1);
t.setText("cake");
}