- public class AntActivity extends Activity {
- private Context context;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- this.context = this;
- /***
- * 特别说明这两行代码,当加载一个布局文件的时候请使用以下方法导入。
- * 如导入main.xml这个布局文件的时候用以下方法。
- * 不要使用 以下代码 如
- * LinearLayout ll = (LinearLayout) this.findViewById(R.layout.main);
- * 因为main这个布局不是main.xml 文件下的一个布局,所以如果使用上一行代码的话 会报空指针的
- * 简单说,如果导入的是一个布局文件 那么使用LayoutInflater 如果加载的是一个布局文件中的子布局,使用findviewbyid()
- */
- LayoutInflater inflater = LayoutInflater.from(this);
- LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.main,null);
- /*****************************************************************************************/
android开门动画效果
最新推荐文章于 2022-08-18 18:34:02 发布