LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout linear = (LinearLayout)inflater.inflate(R.layout.inflation, null);
setContentView(linear);
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View inflate(int resource, ViewGroup root);
1. getSystemService
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
2. LayoutInflater
LayoutInflater inflater = LayoutInflater.from(this);
3. View
LinearLayout linear = (LinearLayout)View.inflate(this, R.layout.main, null);
LinearLayout linear = new LinearLayout(this);
linear.setOrientation(LinearLayout.VERTICAL);
TextView text = (TextView)View.inflate(this, R.layout.mytext, null);
linear.addView(text);
留言列表