首页 文章 精选 留言 我的

精选列表

搜索[数据脱敏],共10000篇文章
优秀的个人博客,低调大师

Android数据填充器LayoutInflater

LayoutInflater类在应用程序中比较实用,可以叫布局填充器,也可以成为打气筒,意思就是将布局文件填充到自己想要的位置,LayoutInflater是用来找res/layout/下的xml布局文件,并且实例化这个XML文件成为一个View,有点类似于类似于findViewById(),但是findViewById()是找xml布局文件下的具体widget控件(Button、TextView)。对于一个没有被载入或者想要动态载入的界面,都需要使用LayoutInflater.inflate()来载入;对于一个已经载入的界面,使用Activiyt.findViewById()方法来获得其中的界面元素。 LayoutInflater实例方式 首先简单看下三种简单的实例方式: 1 2 3 LayoutInflater layoutInflater = getLayoutInflater(); LayoutInflater layoutInflater2 = LayoutInflater.from( this ); LayoutInflater layoutInflater3 = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 第一种getLayoutInflater方式: 1 2 3 public LayoutInflater getLayoutInflater() { return getWindow().getLayoutInflater(); } 第二种实现方式: 1 2 3 4 5 6 7 8 public static LayoutInflater from(Context context) { LayoutInflater LayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (LayoutInflater == null ) { throw new AssertionError( "LayoutInflater not found." ); } return LayoutInflater; } 后两种调用的都是getSystemService,第一种也是~ LayoutInflater实现Demo LayOutInflater填充布局的时候有四种方法,Demo使用第一种: resource:需要加载布局文件的id,需要将这个布局文件中加载到Activity中来操作。 root:inflate()会返回一个View对象如果root不为null,就将这个root作为根对象返回,作为这个xml文件的根视图,如果是null,那么这个xml文件本身就是一个根视图: 1 2 3 4 5 6 public View inflate ( int resource, ViewGroup root) public View inflate (XmlPullParser parser, ViewGroup root) public View inflate (XmlPullParser parser, ViewGroup root, boolean attachToRoot) public View inflate ( int resource, ViewGroup root, boolean attachToRoot) 看下实现的结果: 在主窗体中定义一个按钮,这个代码就不贴了~直接写点击事件的处理吧: 定义一个Item文件: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <?xml version= "1.0" encoding= "utf-8" ?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:id= "@+id/test" android:layout_width= "match_parent" android:layout_height= "match_parent" android:orientation= "vertical" > <TextView android:id= "@+id/inflate_txt" android:layout_width= "match_parent" android:layout_height= "match_parent" android:text= "测试" /> </LinearLayout> 点击事件的处理: 1 2 3 4 5 6 7 8 9 10 LayoutInflater layoutInflater = getLayoutInflater(); View view = layoutInflater.inflate(R.layout.item, null ); TextView text = (TextView) view.findViewById(R.id.inflate_txt); text.setText( "http://www.cnblogs.com/xiaofeixiang" ); text.setTextSize( 18 ); text.setTextColor(Color.RED); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity. this ); builder.setView(view); AlertDialog alertDialog = builder.create(); alertDialog.show(); 本文转自Fly_Elephant博客园博客,原文链接:http://www.cnblogs.com/xiaofeixiang/p/4060705.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

docker的数据卷管理

mkdir -p /data/volumes 挂载目录 1 2 3 [root@web01~] #dockerrun-d--namenginx-volumes-v/data/volumes:/datanginx 1263f51d5bd1114c7f1582a0efb68266ce367629f01a64693cd15cf115165392 本地的 /data/volumes 挂载到容器的 /data 目录下 3.进入容器写文件测试 1 2 3 4 5 6 7 8 9 10 11 12 13 [root@web01~] #dockerps-a CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES 1263f51d5bd1nginx "nginx-g'daemonoff" 5minutesagoUp5minutes80 /tcp ,443 /tcp nginx-volumes a04f5eee61b5nginx "nginx-g'daemonoff" 15minutesagoUp15minutes443 /tcp ,59.110.25.215:89->80 /tcp dokcer-volumes 1f3d2f356995nginx "nginx-g'daemonoff" 41minutesagoUp41minutes443 /tcp ,59.110.25.215:88->80 /tcp mynginx [root@web01~] #bashdockerin.sh1f3d2f356995 root@1263f51d5bd1:/ #cd/data root@1263f51d5bd1: /data #ls root@1263f51d5bd1: /data #touchtest01test02 root@1263f51d5bd1: /data #ls test01 test02 root@1263f51d5bd1: /data # 4.linux本机查看 1 2 3 4 5 6 7 [root@web01volumes] #ll total0 -rw-r--r--1rootroot0Jan322:16test01 -rw-r--r--1rootroot0Jan322:16test02 [root@web01volumes] #pwd /data/volumes [root@web01volumes] # 5.挂载多个目录 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [root@web01volumes] #dockerrun-d--namenginx-volumes02-v/data/volumes2:/data/volumes2-v/data/volumes3:/data/volumes3nginx 5b33955e8addab36c3c183a754d7f82e3ba6c94f1b865d1f4ef366af8ba9e67b [root@web01volumes] # [root@web01~] #bashdockerin.sh5b33955e8addab36c root@5b33955e8add:/ #cd/data/ root@5b33955e8add: /data #ls volumes2volumes3 root@5b33955e8add: /data #touchvolumes2/002 root@5b33955e8add: /data #touchvolumes3/003 root@5b33955e8add: /data # 也是完全OK的 [root@web01data] #tree . ├──volumes │├──test01 │└──test02 ├──volumes2 │└──002 └──volumes3 └──003 3directories,4files [root@web01data] # 6.docker的劵共享机制 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 [root@web01data] #dockerrun-d--namenginx-volumes-from--volumes-fromnginx-volumes02nginx 3342b2a88ba7121ec19e66fc388d8a19e5499e93fe786452bba295f66c9a1904 nginx-volumes02是一个容器,此容器挂载了两个目录 那么nginx-volumes-from将继承nginx-volumes02的目录,不管nginx-volumes02是否运行 [root@web01~] #bashdockerin.sh3342b2a88ba7121e root@3342b2a88ba7: /data #cdvolumes2 root@3342b2a88ba7: /data/volumes2 #ls 002 root@3342b2a88ba7: /data/volumes2 #touch00vo root@3342b2a88ba7: /data/volumes2 #cd../ root@3342b2a88ba7: /data #ls volumes2volumes3 root@3342b2a88ba7: /data #cdvolumes3 root@3342b2a88ba7: /data/volumes3 #ls 003 root@3342b2a88ba7: /data/volumes3 #touch003vo root@3342b2a88ba7: /data/volumes3 # linux系统查看 [root@web01data] #tree . ├──volumes │├──test01 │└──test02 ├──volumes2 │├──002 │└──00vo └──volumes3 ├──003 └──003vo 3directories,6files [root@web01data] # 本文转自 小小三郎1 51CTO博客,原文链接:http://blog.51cto.com/wsxxsl/1888733,如需转载请自行联系原作者

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册