android 从layout中动态获取组件id

LayoutInflater flater = LayoutInflater.from(this);

  View view = flater.inflate(R.layout.example, null);

获取布局中的控件。

  button = (Button) view.findViewById(R.id.button);

  textView = (TextView)view.findViewById(R.id.tview);