I'm probably making some silly mistake.
I have a custom view and use LayoutInflater to get the layout from an XML. Now , 开发者_运维百科say I have a button called bt1. Normally , I would use findViewById , but that isn't working.
How do I get the button INSIDE that custom view?
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");
}
You have to use:
TextView t = (TextView)lytContainer.findViewById(R.id.bt1);
精彩评论