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);

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()