你可以通过视图的getWidth()和getHeight()来获取视图的宽度和高度。 但是,可能会让你失望的是,如果你直接在onCreate方法内调用这两个函数,你会的到0。 为什么呢? 这是因为,当onCreate被调用的时候,视图的内容正在被LayoutInflater来填充xml布局。 这个过 ...
分类:
其他好文 时间:
2016-05-28 19:03:59
阅读次数:
199
咕嘟咕嘟 public class UserFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanc... ...
分类:
其他好文 时间:
2016-05-26 10:15:17
阅读次数:
130
inflate()的作用就是将一个用xml定义的布局文件查找出来,注意与findViewById()的区别,inflate是加载一个布局文件,而findViewById则是从布局文件中查找一个控件。 1.获取LayoutInflater对象有三种方法 LayoutInflater inflater= ...
分类:
其他好文 时间:
2016-05-19 10:16:58
阅读次数:
139
public Dialog createDialog(Context context) { dialog = new Dialog(context, R.style.Theme_DataSheet); inflater = LayoutInflater.from(context); view = i ...
分类:
其他好文 时间:
2016-05-14 10:14:24
阅读次数:
251
自定义对话框 //自定义对话框 public void bt_4(View v) { //1-Layout文件加载器 //LayoutInflater layoutInflater=getLayoutInflater(); // View view=layoutInflater.inflate(R. ...
分类:
其他好文 时间:
2016-05-13 19:11:29
阅读次数:
249
自定义对话框 //自定义对话框 public void bt_4(View v) { //1-Layout文件加载器 //LayoutInflater layoutInflater=getLayoutInflater(); // View view=layoutInflater.inflate(R. ...
分类:
其他好文 时间:
2016-05-13 17:11:23
阅读次数:
202
Tag不像ID是用标示view的。Tag从本质上来讲是就是相关联的view的额外的信息。它们经常用来存储一些view的数据,这样做非常方便而不用存入另外的单独结构。
convertView中的TAG
1. 对于使用了LayoutInflater对象进行View扩充的Tag的使用
在之前,在adapter中,我们在getV...
分类:
其他好文 时间:
2016-05-13 02:21:51
阅读次数:
174
在做项目的时候 ,做到了一个Activity里面有两个Tab切换,每一个Tab是一个Fragment展示内容,当两个Tab来回切换的时候,报了一个错误
经过查找原因,原来是Fragment中OnCreateView()的方法调用错了:
正确的方法应该是:
查阅多方资料得知,我们都LayoutInflater的使用存在误区
我们最常用的便是 LayoutI...
分类:
移动开发 时间:
2016-05-12 23:49:17
阅读次数:
231
在上篇文章中我们主要讲解了LayoutInflater渲染xml布局文件的流程,文中讲到如果在渲染之前为LayoutInflater设置了Factory,那么在渲染每一个View视图时都会调用Factory的onCreateView()方法,因此可以拿onCreateView()方法做切入口实现主题切换功能。如果你不清楚LayoutInflater的渲染流程,请点击这里。今天我们就从实战出发来实现自己的主题切换功能。...
分类:
移动开发 时间:
2016-05-12 19:12:18
阅读次数:
321
自定义loadmoreListView 完成对数据的下滑加载,和 加载状态的显示的处理模板代码package xiaoxu.com.lifeservice.ui.loadmore;import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import an...
分类:
其他好文 时间:
2016-05-12 18:24:48
阅读次数:
134