android 字定义GridView 引用自己的定义布局
生活随笔
收集整理的这篇文章主要介绍了
android 字定义GridView 引用自己的定义布局
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
如果你这个自定义的 view要在xml中使用,那么必须使用构造方法含有两个参数或者两个参数以上的。 否则一个参数的构造方法就可以。
在构造方法中使用 inflate(context, Rlayout.main_activity.xml, GripView)
public class CustomView extends ViewGroup {public CustomView(Context context, AttributeSet attrs) {super(context, attrs);inflate(context, R.layout.activity_main, this);}@Overrideprotected void onLayout(boolean changed, int l, int t, int r, int b) {} }调用了这个方法之后就可以直接在view中findViewById去寻找对应xml文件中的控件进行操作!!!
总结
以上是生活随笔为你收集整理的android 字定义GridView 引用自己的定义布局的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: NSIS FileOpen打开读写文件操
- 下一篇: hibernate demo 搭建