Android菜鸟日记

29 杂记

一、LayoutInflaterfindViewByID

findViewByID就是通常我们用来获取view方法。

前提是需要 当前activity已经setContentView()了。

如果是使用LayoutInflater

是有两种情况

情况一:

使用LayoutInFlater.from(context ct)获取LayoutInflater 对象

然后通过LayoutInflater.inflater(R.layout.xx,null);来获得view 对象。

情况二:

通过(LayoutInFlater)getSystemService(LAYOUT_INFLATER_SERVICE);来获取LayoutInflater 对象

总结一下

findViewByID:是通过 viewid(R.id.xx) 来获取的。

LayoutInflater:是通过R.layout.xx是通过layout来获取的。

二、横竖屏切换

方法一:

AndroidMainIfest.xml里面的

<activity标签里写 android:screenOrientation属性>

方法二:

首先在Activity注册android:configChanges=true;

然后在代码中重写

onConfigurationChanged()函数。

当屏幕方向改变的时候就会调用此方法。

代码中写入

If(this.getResources().getConfigurartion().orientation==Configurartion.Orientation_Portrait)

{

//当竖屏时

}

………………………………………………………………………………………_LANDSCAPE

{

//当横屏时

}

方法三:

这个方法意在:当横竖屏切换的时候会相应onSaveInstanceState()函数,然后重新砸入当前Activity,最后相应onRestoreInstanceState()函数。通过这两个函数进行屏幕横竖屏切换的处理。

2012-01-09

poolo

更多相关文章

  1. eclipse使用appcompat_v7库无法找到android:Widget.Material.Act
  2. Android(安卓)Studio sdk tools文件夹下文件缺失问题以及解决方
  3. Android(安卓)设备监听网络状态变化
  4. Android中的注解
  5. 浅谈Java中Collections.sort对List排序的两种方法
  6. 箭头函数的基础使用
  7. Python技巧匿名函数、回调函数和高阶函数
  8. Python list sort方法的具体使用
  9. python list.sort()根据多个关键字排序的方法实现

随机推荐

  1. android 与C/C++混合编程小例子讲解o
  2. Android入门学习_Android获取来电号码
  3. eclipse ADT插件安装碰到的错误
  4. Android(安卓)Bugly 热修复 快速接入
  5. Android-telephony各文件解释
  6. 中间凹陷的 BottomNavigationView
  7. 十四、ContentProvider往通讯录添加联系
  8. 新浪微博2.5.1 for Android(安卓)去广告
  9. android studio导出apk步骤
  10. git clone代码断点续传解决办法