android 获得 View
16lz
2021-01-23
layout/tab_item_view.xml 部分代码
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" > <ImageView android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" android:padding="3dp" > </ImageView> <TextView android:id="@+id/textview" style="@style/tab_item_text_style" android:layout_width="wrap_content" android:layout_height="wrap_content" > </TextView></LinearLayout>
获得View 的方法
private View getTabItemView(int index) {View view = LayoutInflater.from(this).inflate(R.layout.tab_item_view,null);ImageView imageView = (ImageView) view.findViewById(R.id.imageview);TextView textView = (TextView) view.findViewById(R.id.textview);return view;}
更多相关文章
- ANDROID图片压缩代码
- Android 如何在Java代码中手动设置控件的marginleft
- android典型代码系列(十)------获取一个应用程序的权限信息(反射
- android 2.2+ 完全退出程序的方法今天贡献了
- Android保持屏幕常亮的方法
- android播放音乐文件代码
- android 4.0.3 dhcpcd使用方法
- Android camera调用出现错误解决方法
- Android Studio常见错误及解决方法汇总