安卓中加载布局文件的三种方法
1、方法1
LinearLayout layout=(LinearLayout)LayoutInflater.from(getApplicationContext()).inflate(R.layout.list_view_item_text, null);
LinearLayout layout=(LinearLayout)LayoutInflater.from(MainActivity.this).inflate(R.layout.list_view_item_text, null);
2、方法2
LayoutInflater layoutInflater=(LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout=(LinearLayout)layoutInflater.inflate(R.layout.list_view_item_text, null);
3、方法3
LinearLayout layout=(LinearLayout)getLayoutInflater().inflate(R.layout.list_view_item_text, null);
LinearLayout layout=(LinearLayout)MainActivity.this.getLayoutInflater().inflate(R.layout.list_view_item_text, null);