用 Activity获取当前UI layout中的 view
1,View view = findViewById(R.id.layout_id);
layout_id为xml文件中指定的组件id.
2,View view = mActivity.getWindow()
.getDecorView().findViewById(android.R.id.content);
--------------------------------------------------------------------------------------
LayoutInfalter的获取方法
1. LayoutInflater inflater = mActivity.getLayoutInflater();
2. LayoutInflater inflater = LayoutInflater.from(context);
3. LayoutInflater inflater = (LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
本文介绍了在Android开发中如何通过Activity获取当前UI布局中的View组件,包括直接通过ID查找及使用LayoutInflater加载布局的方法。
3万+

被折叠的 条评论
为什么被折叠?



