首页 文章 精选 留言 我的

精选列表

搜索[笔记工具],共10000篇文章
优秀的个人博客,低调大师

Android笔记: 解决ScrollView嵌套ListView的冲突方法

范例: 1.MainActivity代码: 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 public class MainActivity extends Activity { // 只要在设置ListView的Adapter后调用此静态方法Utility.setListViewHeightBasedOnChildren(listview); // 即可让ListView正确的显示在其父ListView的ListItem中。 // 但是要注意的是,子ListView的每个Item必须是LinearLayout,不能是其他的,因为其他的Layout(如RelativeLayout) // 没有重写onMeasure(),所以会在onMeasure()时抛出异常。 private ArrayList<String> dataList; private ListView listview; private ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_main); dataList = new ArrayList<String>(); for ( int i = 0 ; i < 5 ; i++) { String str = "第" + i + "行" ; dataList.add(str); } img = (ImageView) findViewById(R.id.imageView1); listview = (ListView) findViewById(R.id.listView1); listview.setAdapter( new BaseAdapter() { @Override public View getView( int position, View convertView, ViewGroup parent) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.item, null ); TextView tv = (TextView) layout.findViewById(R.id.tv_item); String str = dataList.get(position); tv.setText(str); return layout; } @Override public long getItemId( int position) { return 0 ; } @Override public Object getItem( int position) { return null ; } @Override public int getCount() { return dataList.size(); } }); Utility.setListViewHeightBasedOnChildren(listview); } } 2.Utility代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null ) { // pre-condition return ; } int totalHeight = 0 ; for ( int i = 0 ; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null , listView); listItem.measure( 0 , 0 ); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1 )); listView.setLayoutParams(params); } } 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1290605,如需转载请自行联系原作者

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

[Android学习笔记六] Toast 更长时间显示

Android Toast是一种比较特殊的显示信息的机制,其没有焦点,并且显示一段时间之后就自动消失。Android 中提供的显示时长通过Toast.LENGHT_LONG和Toast.LENGTH_SHORT来指定,底层具体代表的时间长度分别是3.5s和2.0s。 本文介绍如何使得Toast显示的时间更长或者指定显示时间长度。 1. 基本用法代码示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 /** *Toast默认的长时间显示3.5s */ @OnClick (R.id.one_button) public void onClickOneButton(){ Toast.makeText( this , "HelloWorld" ,Toast.LENGTH_LONG).show(); } /** *Toast默认的短时间显示2.0s */ @OnClick (R.id.two_button) public void onClickTwoButton(){ Toast.makeText( this , "HelloWorld" ,Toast.LENGTH_SHORT).show(); } 2. 通过android.os.CountDownTimer类实现Toast的显示和消失 通过点击下图中的底端左Button使得Toast显示,右Button使得Toast消失。 代码示例: 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 36 37 38 39 40 /** *使用CountDownTimer实现Toast自定义时间显示 */ @Bind (R.id.three_textView) public TextViewthreeTextView; private ToastmCountDownTimeToast; public CountDownTimercdt= new CountDownTimer( 60 * 1000 , 1000 ){ @Override public void onTick( long millisUntilFinished){ threeTextView.setText( "Time剩余:" +(millisUntilFinished/ 1000 )+ "s" ); if ( null !=mCountDownTimeToast){ mCountDownTimeToast.show(); } } @Override public void onFinish(){ threeTextView.setText( "显示完成" ); if ( null !=mCountDownTimeToast){ mCountDownTimeToast.cancel(); } } }; @OnClick ({R.id.three_button_start,R.id.three_button_cancel}) public void onClickThreeButton(Viewv){ if ( null ==mCountDownTimeToast){ mCountDownTimeToast=makeToast( this ); mCountDownTimeToast.setGravity(Gravity.TOP|Gravity.LEFT, 30 , 30 ); } if (v.getId()==R.id.three_button_start){ cdt.start(); Log.d(TAG, "CountDownTimerstartshow" ); } if (v.getId()==R.id.three_button_cancel){ cdt.cancel(); threeTextView.setText( "取消" ); Log.d(TAG, "CountDownTimercancel" ); } } Toast对象的View布局文件(view_toast.xml) 1 2 3 4 5 6 7 8 9 <? xml version = "1.0" encoding = "utf-8" ?> < TextView xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:background = "#ef3939" android:orientation = "vertical" style = "@android:style/TextAppearance.DeviceDefault.Medium" android:gravity = "center_vertical|center_horizontal" android:padding = "10dp" android:text = "&quot;HelloWorld&quot;" android:textColor = "#f7f9fb" > </ TextView > 创建Toast对象(下文中创建Toast对象使用该方法) 1 2 3 4 5 6 7 public static ToastmakeToast(Contextcontext){ Toasttoast= new Toast(context); toast.setDuration(Toast.LENGTH_SHORT); TextViewview=(TextView)LayoutInflater.from(context).inflate(R.layout.view_toast, null ); toast.setView(view); return toast; } 上述代码通过CountDownTimer实现指定Toast显示时长和控制Toast显示与消失,重构之后代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 public void showToast1( final Toasttoast, long duration){ final long SHORT= 2000 ; final long LONG= 3500 ; final long ONE_SECOND= 1000 ; final long d=duration<=SHORT?SHORT:duration>LONG?duration:LONG; new CountDownTimer(Math.max(d,duration),ONE_SECOND){ @Override public void onTick( long millisUntilFinished){ toast.show(); } @Override public void onFinish(){ toast.cancel(); } }.start(); } 3.通过Handler消息机制实现 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 public void showToast2( final Toasttoast, long duration){ final long SHORT= 2000 ; final long LONG= 3500 ; final long ONE_SECOND= 1000 ; final long d=duration<=SHORT?SHORT:duration>LONG?duration:LONG; final int what= 1 ; final Handlerhandler= new Handler(){ long remainder=d; @Override public void handleMessage(Messagemsg){ if (msg.what==what){ toast.show(); if (remainder>=ONE_SECOND){ remainder-=ONE_SECOND; sendEmptyMessageDelayed(what,ONE_SECOND); } else { removeMessages(what); } } } }; handler.sendEmptyMessage(what); } 其实这种实现和CountDownTimer实现的机制一样的。 4. Toast的指定时长显示其实就是不断的调用Toast的show()方法,其中show()方法中实现了将Toast对象添加到INotificationManager的Toast队列中去。具体细节可参见Toast(android.widget.Toast)源码。 5. 为什么要给Toast指定显示时长呢? 这或许不是个好主意。Toast的无焦点短时间自动消失机制就是为了给用户显示信息而不会产生较大干扰。如果长时间显示并且具有更多交互和事件处理,这就背离了Toast的本意,这样的场景可以考虑使用Notification,Dialog来实现。 使用Toast场景中更多的是关注其View和显示的位置,这可以实现更多有意思的东西,比如冒泡提示,使用向导等。在实践中则需要根据具体情况慎重选择和合理应用。 本文转自 secondriver 51CTO博客,原文链接:http://blog.51cto.com/aiilive/1717222,如需转载请自行联系原作者

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

学习笔记-ELK5安装X-Pack

elk5和之前的版本不太一样,他将之前的三方插件集成到了xpack中,想要使用高级功能,必须安装xpack这个插件,但是这个xpack确实让人很头疼,如果配置不正确,es是收不到logstash传来的数据的,更别提Kibana能展示他了,根本就搜不到索引名称。 一、elasticsearch5按这X-Pack的步骤: 1、elasticsearch安装X-Pack: 在每个集群节点的运行ES_HOME里运行bin/elasticsearch-plugin install x-pack,我这里使用的是yum安装,所以ES_HOME是/usr/share/elasticsearch/。 1 bin /elasticsearch-plugin install x-pack 允许X-Pack创建上面的一系列索引。 2、重启elastcsearch服务 1 systemctlrestartelasticsearch 二、Kibana安装X-Pack 1、安装xpack 进入Kibana的安装目录,这里使用的是yum安装,在/usr/share/kibana下面,运行一下命令,在线安装: 1 2 3 cd /usr/share/kibana bin /kibana-plugin install x-pack systemctlrestartkibana 2、配置Kibana配置文件 将配置文件中下面两项取消注释: 这一个细节必须注意,重中之重,不然Kibana会连接不上es,密码是默认的Kibana登录密码,后续可以修改。 1 2 elasticsearch.username: "elastic" elasticsearch.password: "changeme" 3、登录Kibana 在浏览器上访问http://localhost:5601会出现一下页面,但是会出现认证登录。 三、登录认证 官网是这么说的,安装X-Pack后需要认证,而默认帐号:elastic,密码:changeme 四、添加logstash配置文件 1、添加logstash测试文件 在/etc/logstash/conf.d下面写一个测试文件 1 2 3 4 5 6 7 8 9 10 11 input{ stdin{} } output{ elasticsearch{ hosts=> "10.1.12.169:9200" index=> "test-messages-%{+YYYY.MM.dd}" user=> 'elastic' #需要在添加帐号密码,不然无法将数据传输到elasticsearch上 password=> 'changeme' } } 2、测试文件是否可用 1 2 [root@elkconf.d] #logstash-f/etc/logstash/conf.d/test.conf-t ConfigurationOK 3、测试输入是否成功 测试成功可以打开文件,输入进行测试了 1 2 3 4 [root@elkconf.d] #logstash-f/etc/logstash/conf.d/test.conf [root@elkconf.d] #logstash-f/etc/logstash/conf.d/test.conf Thestdinpluginisnowwaiting for input: helloworld 测试中多顶着es、logstash的日志,出了问题知道错在哪! 技术水平有限,先这么着吧。 本文转自 wangpengtai 51CTO博客,原文链接:http://blog.51cto.com/wangpengtai/1910397,如需转载请自行联系原作者

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

docker学习笔记(三)——创建自定义镜像

首先拉取一个镜像,在这里以NGINX为例 1 2 3 4 [root@DockServeropt] #dockerpullnginx [root@DockServeropt] #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE nginxlatestb8efb18f159b3weeksago107MB 启动NGINX镜像,映射出端口 1 2 3 4 5 [root@DockServeropt] #dockerrun--namewebserver-d-p80:80nginx 8f62585b370ca34eb8c438adbab0f972e1990cee25000a742c6a2d8e7ee7ba38 [root@DockServeropt] #dockerps CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES 8f62585b370cnginx "nginx-g'daemon..." 6secondsagoUp6seconds0.0.0.0:80->80 /tcp webserver 访问端口,直接用命令行访问, 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@DockServeropt] #curlhttp://127.0.0.1 <!DOCTYPEhtml> <html> < head > <title>Welcometonginx!< /title > <style> body{ width:35em; margin:0auto; font-family:Tahoma,Verdana,Arial,sans-serif; } < /style > < /head > <body> <h1>Welcometonginx!< /h1 > <p>Ifyouseethispage,thenginxwebserverissuccessfullyinstalledand working.Furtherconfigurationisrequired.< /p > <p>Foronlinedocumentationandsupportpleasereferto <ahref= "http://nginx.org/" >nginx.org< /a >.<br/> Commercialsupportisavailableat <ahref= "http://nginx.com/" >nginx.com< /a >.< /p > <p><em>Thankyou for usingnginx.< /em >< /p > < /body > < /html > 可以看到能够访问在nginx docker里的东东了,下面我们修改下首页内容 进入nginx docker 里面进行修改 1 2 3 4 5 进入docker [root@DockServeropt] #dockerexec-itwebserverbash root@8f62585b370c:/ #echo'<h1>Hello,Docker!</h1>'>/usr/share/nginx/html/index.html root@8f62585b370c:/ #exit exit 再次访问看看 1 2 [root@DockServeropt] #curlhttp://127.0.0.1 <h1>Hello,Docker!< /h1 > 可以看出,已经修改成功,我们保存成镜像 1 2 3 4 5 6 7 8 9 10 11 12 [root@DockServeropt] #dockercommit--author"DingJin<dingjin@gmail.com>"--message"修改nginx默认网页"webserverwebserver:v2 sha256:ca35d11b57bac6e3e4ebab15aaff528c8530f7f5e59e00f58fa61e86edf1aa91 [root@DockServeropt] #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE webserverv2ca35d11b57ba6secondsago107MB nginxlatestb8efb18f159b3weeksago107MB 已经可以看到webserver:v2镜像了,运行下 [root@DockServeropt] #dockerrun--nameweb2-d-p81:80webserver:v2 1647edeba49aa664c0ccf642248f6b30b36c6b08990ede580a5803f1a59ae545 [root@DockServeropt] #curlhttp://127.0.0.1:81 <h1>Hello,Docker!< /h1 > 可以了解以下命令, 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 查看webserver做了哪些更改,即和源镜像对比不同 [root@DockServeropt] #dockerdiffwebserver C /root A /root/ .bash_history C /run A /run/nginx .pid C /var C /var/cache C /var/cache/nginx A /var/cache/nginx/uwsgi_temp A /var/cache/nginx/client_temp A /var/cache/nginx/fastcgi_temp A /var/cache/nginx/proxy_temp A /var/cache/nginx/scgi_temp C /usr C /usr/share C /usr/share/nginx C /usr/share/nginx/html 查看webserver:v2历史文件变动记录 [root@DockServeropt] #dockerhistorywebserver:v2 IMAGECREATEDCREATEDBYSIZECOMMENT ca35d11b57ba4minutesagonginx-gdaemonoff;98B修改nginx默认网页 b8efb18f159b3weeksago /bin/sh -c #(nop)CMD["nginx""-g""daem...0B <missing>3weeksago /bin/sh -c #(nop)STOPSIGNAL[SIGTERM]0B <missing>3weeksago /bin/sh -c #(nop)EXPOSE80/tcp0B <missing>3weeksago /bin/sh -c ln -sf /dev/stdout /var/log/ngi ...0B <missing>3weeksago /bin/sh -capt-getupdate&&apt-getinst...52.2MB <missing>3weeksago /bin/sh -c #(nop)ENVNJS_VERSION=1.13.3....0B <missing>3weeksago /bin/sh -c #(nop)ENVNGINX_VERSION=1.13....0B <missing>3weeksago /bin/sh -c #(nop)MAINTAINERNGINXDocker...0B <missing>3weeksago /bin/sh -c #(nop)CMD["bash"]0B <missing>3weeksago /bin/sh -c #(nop)ADDfile:fa8dd9a679f473a...55.2MB 结合上篇,我们上传到本地私有仓库,然后就直接可以在本地调用了~~ 本文转自 jackjiaxiong 51CTO博客,原文链接:http://blog.51cto.com/xiangcun168/1957431

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

docker学习笔记(一)——centos7 安装docker

Docker 最低支持 CentOS 7, 推荐Centos7.3版本 配置yum源 1 2 3 4 5 6 7 #tee/etc/yum.repos.d/docker.repo<<-'EOF'[dockerrepo] name=DockerRepository baseurl=https: //yum .dockerproject.org /repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https: //yum .dockerproject.org /gpg EOF 安装 Docker 更新yum软件源缓存,并安装docker-engine。 1 2 #yumupdate #yuminstalldocker-engine 启动 Docker 引擎 1 2 #systemctlenabledocker #systemctlstartdocker 以上就安装完了docker 本文转自 jackjiaxiong 51CTO博客,原文链接:http://blog.51cto.com/xiangcun168/1957360

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

Android学习笔记--Android开发时常用控件(三)

ProgressBar(进度条) ListView(很重要的显示控件) 例:<ProgressBarandroid:id="@+id/pBar" Style="?Android:attr/progressBarStyleHorizontal"--水平方向的进度条 Android:layout_width="200dp" Android:layout_height="wrap_content" Android:visibility="gone" Android:max=200 /> 代码:1.声明变量 2.根据ID取得控件对象findViewById 3.设置监听类 ClassButtonLinstenerimplementsOnClickListener{ PublicvoidonClick(Viewv){ If(i==0){ pBar.setVisibility(View.VISIBLE); } Elseif(i<pBar.getMax()){ pBar.setProgress(i);--设置主进度条的当前值 pBar.setSecondaryProgress(i+10);--设置第二进度条的当前值 } Else{ pBar.setVisbility(View.GONE); } I=i+10; } } 4.绑定事件 myButton.setOnClickListener(newButtonLinstener()); 例:main布局文件 <ListViewandroid:id="@id/android:list" Android:layout_width="fill_parent" Android:layout_height="wrap_content" Android:drawSelecrorOnTop="false" Android:scrollbars="vertical"/> User布局文件略(两个TextView) 代码:publicclassActivityextendsListActivity{ super.onCreate(savedInstanceState); setContentView(R.layout.main); //用一个集合对象装数据 ArrayList<HashMap<Stirng,String>>list=newArrayList<HashMap<Stirng,String>>(); HashMap<String,String>Map1=newHashMap<String,String>(); HashMap<String,String>Map2=newHashMap<String,String>(); HashMap<String,String>Map3=newHashMap<String,String>(); Map1.put("user_name","zhangsan"); Map1put("user_ip","192.168.0.1"); Map2.put("user_name","lisi"); Map2.put("user_ip","192.168.0.2"); Map3.put("user_name","wangwu"); Map3.put("user_ip","192.168.0.3"); List.add(Map1); List.add(Map2); List.add(Map3); //listActivity对象,map,第二个布局文件,对应hashMap的值对(可想象成列),控件显示的位置 SimpleAdapterlistAdapter=newSimpleAdapter(this,list,R.layout.user,newString[]{"user_name","user_ip"},newint[]{R.id.user_ip,R.id.user_name}); setListAdapter(listAdapter); } //重写 ProtectedvoidonListItemClick(ListViewlv,Viewv,intposition,longid){ super.onListItemClick(1,v,position,id); System.out.println("id--------"+id); System.out.println("position-------"+position) } 本文转自My_King1 51CTO博客,原文链接:http://blog.51cto.com/apprentice/1360573,如需转载请自行联系原作者

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

Android笔记:Android-Universal-Image-Loader 属性设置

注:1.ImageView一定要在布局里 2.使用前先在清单里application里配置name属性(包名+类名) 1.此类的功能: 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 36 37 38 1 //设置图片在下载期间显示的图片 2 showStubImage(R.drawable.ic_launcher) 3 4 //设置图片Uri为空或是错误的时候显示的图片 5 showImageForEmptyUri(R.drawable.ic_empty) 6 7 //设置图片加载/解码过程中错误时候显示的图片 8 showImageOnFail(R.drawable.ic_error) 9 10 //设置图片在下载前是否重置,复位 11 resetViewBeforeLoading() 12 13 //设置下载的图片是否缓存在内存中 14 cacheInMemory() 15 16 //设置下载的图片是否缓存在SD卡中 17 cacheOnDisc() 18 19 //设置图片的解码类型 20 bitmapConfig(Bitmap.Config.RGB_565) 21 22 //设置图片的解码配置 23 decodingOptions(android.graphics.BitmapFactory.Options decodingOptions) 24 25 //设置图片下载前的延迟 26 delayBeforeLoading( int delayInMillis) 27 28 //设置额外的内容给ImageDownloader 29 extraForDownloader(Object extra) 30 31 //设置图片加入缓存前,对bitmap进行设置 32 preProcessor(BitmapProcessor preProcessor) 33 34 //设置显示前的图片,显示后这个图片一直保留在缓存中 35 postProcessor(BitmapProcessor postProcessor) 36 37 //设置图片以如何的编码方式显示 38 imageScaleType(ImageScaleType imageScaleType) 2.此类的两种创建方式: 1 2 3 4 5 6 7 8 9 10 11 12 /** * DisplayImageOptions 创建的两种方式。 */ // 创建默认的DisplayImageOptions DisplayImageOptions option_0=DisplayImageOptions.createSimple(); // 使用DisplayImageOptions.Builder()创建DisplayImageOptions DisplayImageOptions option_1 = new DisplayImageOptions.Builder() .showStubImage(R.drawable.ic_launcher) .showImageOnFail(R.drawable.ic_error) .showImageForEmptyUri(R.drawable.ic_empty).cacheInMemory() .cacheOnDisc().displayer( new RoundedBitmapDisplayer( 20 )) .build(); 3.类中的方法使用: 1 2 3 4 5 6 7 8 9 10 /** * 设置图片的显示方式 * @param displayer */ displayer(BitmapDisplayer displayer) displayer: RoundedBitmapDisplayer( int roundPixels)设置圆角图片 FakeBitmapDisplayer()这个类什么都没做 FadeInBitmapDisplayer( int durationMillis)设置图片渐显的时间 SimpleBitmapDisplayer()正常显示一张图片 1 2 3 4 5 6 7 8 9 10 11 /** * 图片的缩放方式 * @param imageScaleType */ imageScaleType(ImageScaleType imageScaleType) imageScaleType: EXACTLY :图像将完全按比例缩小的目标大小 EXACTLY_STRETCHED:图片会缩放到目标大小完全 IN_SAMPLE_INT:图像将被二次采样的整数倍 IN_SAMPLE_POWER_OF_2:图片将降低 2 倍,直到下一减少步骤,使图像更小的目标大小 NONE:图片不会调整 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1223078,如需转载请自行联系原作者

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

openstack学习笔记六 多节点部署之keystone

keystone 对用户进行验证,每个组件必须得实用一个用户向keystone进行注册,只有成功了,那么这个组件才能正常工作。所以当我们在创建其他组件的时候,也包括keystone本身,都得为这个组件创建一个用户名和密码 keystone也必须知道这些组件到底在什么地方,比如在那台主机上。 User 住宾馆的人 Credentials 开启房间的钥匙 Authentication 宾馆为了拒绝不必要的人进出宾馆,专门设置的机制,只有拥有钥匙的人才能进出 Token 也是一种钥匙,有点特别 Tenant 宾馆 Service 宾馆可以提供的服务类别,比如,饮食类,娱乐类 Endpoint 具体的一种服务,比如吃烧烤,打羽毛球 Role VIP 等级,VIP越高,享有越高的权限 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [root@h1~] #sourcekeystonerc_admin [root@h1~(keystone_admin)] #keystoneendpoint-list +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ | id |region|publicurl|internalurl|adminurl|service_id| +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ |03bf88d48e2648149242a571684fbfce|RegionOne|http: //192 .168.1.201:9696|http: //192 .168.1.201:9696|http: //192 .168.1.201:9696|1100243c5a694bc5857218dd0543297b| |1b5ccdf306484fefadc63d1eeb20de5d|RegionOne|http: //127 .0.0.1:8774 /v3 |http: //127 .0.0.1:8774 /v3 |http: //127 .0.0.1:8774 /v3 |4bda82ded4db46f68428d4e00247c14c| |2408bc6cb5164053b86c0983fd39961a|RegionOne|http: //192 .168.1.201:8080 /v1/AUTH_ %(tenant_id)s|http: //192 .168.1.201:8080 /v1/AUTH_ %(tenant_id)s|http: //192 .168.1.201:8080|30c62c3c0797462a8bd4ff059a71296e| |432e655e85614a5eb69b7de5c5aacf34|RegionOne|http: //192 .168.1.201:8776 /v2/ %(tenant_id)s|http: //192 .168.1.201:8776 /v2/ %(tenant_id)s|http: //192 .168.1.201:8776 /v2/ %(tenant_id)s|5d60cb24769e403cb10bb70cb1077f2b| |4d5c1e505b30467c9966a5e5e93feef0|RegionOne|http: //192 .168.1.201:9292|http: //192 .168.1.201:9292|http: //192 .168.1.201:9292|87d30bb0dd8e44ccba00127f77831e9e| |8683d84884d74e7c8a73513260aec774|RegionOne|http: //192 .168.1.201:8080|http: //192 .168.1.201:8080|http: //192 .168.1.201:8080|e6ced100d94e4f3b86cccfc82e12b83a| |8fa0e177bac746f79e229f16954506fb|RegionOne|http: //192 .168.1.201:8776 /v1/ %(tenant_id)s|http: //192 .168.1.201:8776 /v1/ %(tenant_id)s|http: //192 .168.1.201:8776 /v1/ %(tenant_id)s|dc75a046272548db99e1cbbe93c2025c| |9006207b29a04700922ee55905a7f445|RegionOne|http: //192 .168.1.201:8774 /v2/ %(tenant_id)s|http: //192 .168.1.201:8774 /v2/ %(tenant_id)s|http: //192 .168.1.201:8774 /v2/ %(tenant_id)s|1c9e6e4d00824327bfe4e8e7175317e1| |a9ec253a705c4b3c9848b5bed32e9768|RegionOne|http: //192 .168.1.201:8773 /services/Cloud |http: //192 .168.1.201:8773 /services/Cloud |http: //192 .168.1.201:8773 /services/Admin |81bbcf83509a42e9a867914cde84e9d4| |bcab3bbc3281451494428315b24b0dba|RegionOne|http: //192 .168.1.201:8777|http: //192 .168.1.201:8777|http: //192 .168.1.201:8777|8f54fc4364de49efbeb72020bf2aa176| |e3d9a4fa64bd441ea3fe143b1d72b8a4|RegionOne|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:35357 /v2 .0|02ce8247c5924913a73422bcf5275c40| +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [root@h1~(keystone_admin)] #keystoneservice-list服务 +----------------------------------+------------+--------------+--------------------------------+ | id |name| type |description| +----------------------------------+------------+--------------+--------------------------------+ |8f54fc4364de49efbeb72020bf2aa176|ceilometer|metering|OpenstackMeteringService| |dc75a046272548db99e1cbbe93c2025c|cinder|volume|CinderService| |5d60cb24769e403cb10bb70cb1077f2b|cinderv2|volumev2|CinderServicev2| |87d30bb0dd8e44ccba00127f77831e9e|glance|image|OpenStackImageService| |02ce8247c5924913a73422bcf5275c40|keystone|identity|OpenStackIdentityService| |1100243c5a694bc5857218dd0543297b|neutron|network|NeutronNetworkingService| |1c9e6e4d00824327bfe4e8e7175317e1|nova|compute|OpenstackComputeService| |81bbcf83509a42e9a867914cde84e9d4|nova_ec2|ec2|EC2Service| |4bda82ded4db46f68428d4e00247c14c|novav3|computev3|OpenstackComputeServicev3| |30c62c3c0797462a8bd4ff059a71296e|swift|object-store|OpenstackObject-StoreService| |e6ced100d94e4f3b86cccfc82e12b83a|swift_s3|s3|OpenstackS3Service| +----------------------------------+------------+--------------+--------------------------------+ 1 2 3 4 5 6 7 8 9 [root@h1~(keystone_admin)] #keystonerole-list角色 +----------------------------------+---------------+ | id |name| +----------------------------------+---------------+ |7455105a501842e097e7825257eb5be4|ResellerAdmin| |5d2a5d2f80d442e09b9c3d514ded412e|SwiftOperator| |9fe2ff9ee4384b1894a90878d3e92bab|_member_| |794f590d02344bafb280f37ff29433ae|admin| +----------------------------------+---------------+ 1 2 3 4 5 6 7 8 [root@h1~(keystone_admin)] #keystonerole-create--nametest1 +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ | id |467d36315d9c4e529e9400c606f8d7a2| |name|test1| +----------+----------------------------------+ [root@h1~(keystone_admin)] #keystonerole-deletetest1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [root@h1~(keystone_admin)] #keystoneuser-list用户 +----------------------------------+------------+---------+----------------------+ | id |name|enabled|email| +----------------------------------+------------+---------+----------------------+ |1627cc3d61c04f9db9608e9703a01371|admin|True|root@localhost| |04247710cdf34914a7f5b315ab166731|ceilometer|True|ceilometer@localhost| |cb5e12e30a4a4c1dae57255c184b8b30|cinder|True|cinder@localhost| |632fb20205ea4c40988d7d65b2844ff6|glance|True|glance@localhost| |23c4fb48a5a247d68e50c6b74fb6f035|http|True|| |80069f5c8edc454b8038e7f116df4ff5|neutron|True|neutron@localhost| |adbcaaf58d09495988b57be8e82b4e6b|nova|True|nova@localhost| |4f488ff4859e4973afefea6e7872ed83|swift|True|swift@localhost| +----------------------------------+------------+---------+----------------------+ [root@h1~(keystone_admin)] #keystoneuser-create--namehequan--passhequan--emailhequan2011@sina.com +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ |email|hequan2011@sina.com| |enabled|True| | id |9d12907283b64b02a80f1e98074a9c84| |name|hequan| |username|hequan| +----------+----------------------------------+ 1 2 3 4 [root@h1~(keystone_admin)] #keystoneuser-gethequan##查看信息 [root@h1~(keystone_admin)] #keystoneuser-deletehequan [root@h1~(keystone_admin)] #keystoneuser-password-update--passhequan1hequan##密码更新 [root@h1~(keystone_admin)] #keystoneuser-role-add--userhequan--role_member_--tenant=http#划分角色和租户 1 2 3 4 5 6 7 8 [root@h1~(keystone_admin)] #keystonetenant-list租户 +----------------------------------+----------+---------+ | id |name|enabled| +----------------------------------+----------+---------+ |43986fb013804aa0a04ca277e4d0e69c|admin|True| |1af10fa8077e4b52b3427786bb15e968|http|True| |842da711a1b740ddbf006a9f0a7ee116|services|True| ##内置服务默认都属于services +----------------------------------+----------+---------+ 1 2 3 4 5 6 7 8 9 10 [root@h1~(keystone_admin)] #keystonetenant-create--name123###创建租户123 +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |description|| |enabled|True| | id |c2a2e3aadf614bb08b1fc943157b668e| |name|123| +-------------+----------------------------------+ [root@h1~(keystone_admin)] #keystonetenant-delete123 配置安装keystone 首先创建数据库 使用token登陆keystone 创建服务 endpoint 创建用户 关闭token登陆,使用admin登陆 基本环境 1 2 3 4 5 6 7 192.168.1.204h4.hequan.comh4 ##keystone systemctlstopNetworkManager systemctldisableNetworkManager [root@h4~] #yuminstallcentos-release-openstack-liberty 1 2 3 4 5 6 7 8 9 [root@h4~] #yuminstallopenstack-keystoneopenstack-utilsopenstack-selinux-y [root@h4~] #openstack-db--init--servicekeystone--rootpw123456--passwordkeystone keystonedefaultDBisnotmysql.Wouldyouliketoresettomysqlnow?(y /n ):y mysql-serverisnotinstalled.Wouldyouliketo install itnow?(y /n ):y mysqldisnotrunning.Wouldyouliketostartitnow?(y /n ):y VerifiedconnectivitytoMySQL. Creating 'keystone' database. Initializingthekeystonedatabase,pleasewait... Complete! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [root@h4~] #mysql-uroot-p123456 MariaDB[(none)]>showdatabases; [root@h4keystone] #opensslrand-hex10 73fa731f6fa567630fdd [root@h4keystone] #pwd /etc/keystone [root@h4keystone] #vimkeystone.conf admin_token=73fa731f6fa567630fdd rabbit_host=localhost rabbit_port=5672 rabbit_hosts=$rabbit_host:$rabbit_port rabbit_use_ssl= false rabbit_userid=guest rabbit_password=guest rabbit_login_method=AMQPLAIN rabbit_virtual_host=/ connection=mysql: //keystone :keystone@192.168.1.204 /keystone ###用到上面写的用户名和密码 启动服务 1 2 3 4 5 6 [root@h4keystone] #systemctllist-unit-files|grepkeyston openstack-keystone.servicedisabled [root@h4keystone] #systemctlstartopenstack-keystone.service [root@h4keystone] #systemctlenableopenstack-keystone.service 现在没有用户,只有token 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 cat keystone_token ##创建文件 export SERVICE_TOKEN=73fa731f6fa567630fdd export SERVICE_ENDPOINT=http: //192 .168.1.204:35357/v2.0 export PS1= '[\u@\h\W(keystone_token)]\$' source keystone_token ps aux| grep keystone keystone33431.51.632184468704?Ss20:100:05 /usr/bin/python2 /usr/bin/keystone-all netstat -lntup| grep 35357 tcp000.0.0.0:353570.0.0.0:*LISTEN3343 /python2 keystoneservice-list [root@h4~] #keystoneservice-create--namekeystone--typeidentity--description="keystone" +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |description|keystone| |enabled|True| | id |e0c6163cb7dd42098225f13a3fa4220e| |name|keystone| | type |identity| +-------------+----------------------------------+ 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@h4~] #keystoneendpoint-create--service-ide0c6163cb7dd42098225f13a3fa4220e--publicurl''--internalurl''--adminurl'' 可以找一个模板去抄 [root@h1~(keystone_admin)] #keystoneendpoint-list +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ | id |region|publicurl|internalurl|adminurl|service_id| +----------------------------------+-----------+-------------------------------------------------+-------------------------------------------------+--------------------------------------------+----------------------------------+ |e3d9a4fa64bd441ea3fe143b1d72b8a4|RegionOne|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:5000 /v2 .0|http: //192 .168.1.201:35357 /v2 .0|02ce8247c5924913a73422bcf5275c40| [root@h1~(keystone_admin)] #keystoneservice-list |02ce8247c5924913a73422bcf5275c40|keystone|identity|OpenStackIdentityService| [root@h4~] #keystoneendpoint-create--service-ide0c6163cb7dd42098225f13a3fa4220e--publicurl'http://192.168.1.201:5000/v2.0'--internalurl''--adminurl''--publicurl'http://192.168.1.204:5000/v2.0'--internalurl'http://192.168.1.204:5000/v2.0'--adminurl'http://192.168.1.204:35357/v2.0' +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |adminurl|http: //192 .168.1.204:35357 /v2 .0| | id |810e5faef22f44aebd17f55d1808e3c5| |internalurl|http: //192 .168.1.204:5000 /v2 .0| |publicurl|http: //192 .168.1.204:5000 /v2 .0| |region|regionOne| |service_id|e0c6163cb7dd42098225f13a3fa4220e| +-------------+----------------------------------+ 创建管理员 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 [root@h4~] #keystonetenant-create--nameadmin +-------------+----------------------------------+ |Property|Value| +-------------+----------------------------------+ |description|| |enabled|True| | id |3a331dd90062458b8fcc259ce84be0e5| |name|admin| +-------------+----------------------------------+ [root@h4~] #keystonerole-create--nameadmin +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ | id |c63ed09a433144108a23a592632e2e08| |name|admin| +----------+----------------------------------+ [root@h4~] #keystoneuser-create--nameadmin--pass123456 +----------+----------------------------------+ |Property|Value| +----------+----------------------------------+ |email|| |enabled|True| | id |172b6a61991e4fbeafe9039688eb2afc| |name|admin| |username|admin| +----------+----------------------------------+ [root@h4~] #keystoneuser-role-add--useradmin--tenantadmin--roleadmin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [root@h4~] #cpkeystone_tokenkeystone_token_admin [root@h4~(keystone_admin)] #catkeystone_token_admin unset SERVICE_TOKEN unset SERVICE_ENDPOINT export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=123456 export OS_AUTH_URL=http: //192 .168.1.204:35357 /v2 .0 export PS1= '[\u@\h\W(keystone_admin)]\$' [root@h4~(keystone_admin)] #keystoneuser-list##可以看到就表示成功了 +----------------------------------+-------+---------+-------+ | id |name|enabled|email| +----------------------------------+-------+---------+-------+ |172b6a61991e4fbeafe9039688eb2afc|admin|True|| +----------------------------------+-------+---------+-------+ 关闭token验证 1 2 12 #admin_token=73fa731f6fa567630fdd 13 至此安装完成。 本文转自 295631788 51CTO博客,原文链接:http://blog.51cto.com/hequan/1796108,如需转载请自行联系原作者

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

[转]Android笔记:Fragment与Activity之间的交互

在Activity中有一个FragmentRight. step1.首先,为了在Activity中能够使用FragmentRight,写了一条: 1 fragmentRight = (FragmentRight) getFragmentManager().findFragmentById(R.id.fragmentright); 当然,fragmentright.xml就是FragmentRight的布局文件了。 写了这条以后,就可以在Activity中使用FragmentRight实例的方法了 step2.然后,在FragmentRight中我有个按钮,当按它的时候,要触发一些代码。这时,要在FragmentRight中定义一个接口,和一个方法: 1 2 3 4 // Container Activity must implement this interface public interface OnMyButtonClickListener { public void onMyButtonClick(); //接口中定义一个方法 } 当然,之后要在需要的地方调用这个方法。我是在按FragmentRight上那个按钮时调用它。我的按钮就叫testButton. 慢着,接口的方法要被调用前,当然要先声明接口类型的成员变量: 1 2 3 4 5 6 7 private OnMyButtonClickListener mListener; testButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { mListener.onMyButtonClick(); } }); step3.在FragmentRight的onAttach()方法中给mListener这个成员变量赋个值,不然会出讨厌的nullpointerexception哦。 1 2 3 4 5 6 7 8 9 10 11 12 13 @Override public void onAttach(Activity activity) { super .onAttach(activity); try { mListener = (OnbtnSendClickListener) activity; //这句就是赋初值了。 } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + "must implement OnbtnSendClickListener" ); //这条表示,你不在Activity里实现这个接口的话,我就要抛出异常咯。知道下一步该干嘛了吧? } } step4.在Activity中实现这个接口: ...... extends Activity implements OnMyButtonClickListener{...... 并且,重写该接口中定义的方法吧: 1 2 3 4 5 @Override public void onMyButtonClick() { ...... //在这里该干嘛干嘛呗。 } 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1307721,如需转载请自行联系原作者

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

CCNA学习笔记--路由器的基本配置

路由器简介 路由器能起到隔离广播域的作用,还能在不同网络间转发数据包。路由器实际上是一台特殊用途的计算机,和常见的PC 机一样,路由器有CPU、内存、BOOTROM。路由器没有键盘、硬盘、显示器;然而比起计算机,路由器多了NVRAM、FLASH 以及各种各样的接口。路由器各个部件的作用如下: (1) CPU:中央处理单元,和计算机一样,它是路由器的控制和运算部件。 (2) RAM/DRAM:内存,用于存储临时的运算结果,如:路由表、ARP 表、快速交换缓存、缓冲数据包、数据队列、当前配置。众所周知,RAM 中的数据在路由器断电后是会丢失的。 (3) FLASH:可擦除、可编程的ROM,用于存放路由器的IOS,FLASH 的可擦除特性允许我们更新、升级IOS 而不用更换路由器内部的芯片。路由器断电后,FLASH 的内容不会丢失。FLASH 容量较大时,就可以存放多个IOS 版本。 (4) NVRAM:非易失性RAM,用于存放路由器的配置文件,路由器断电后,NVRAM 中的内容仍然保持。 (5) ROM:只读存储器,存储了路由器的开机诊断程序、引导程序和特殊版本的IOS 软件 (用于诊断等有限用途),ROM 中软件升级时需要更换芯片。 (6) 接口(Interface):用于网络连接,路由器就是通过这些接口和不同的网络进行连接的 路由器的使用与IOS 基本命令 实验拓扑: 1:用户模式和特权模式的切换 Router> //“Router”是路由器的名字,而“>”代表是在用户模式 Router>enable //“enable”命令可以使路由器从用户模式进入到特权模式 Router# Router#disable //“disable”命令则相反,在特权模式下的提示符为“#” Router> 2、IOS 编辑命令与历史命令缓存大小 Router#show history //显示历史命令 Router#terminal editing //打开编辑功能,实际上这是默认的。用上下左右光标键试试移动光标, Router#terminal history size 50 //以上把缓存的历史命令数改为50,默认值为10 Router#terminal no editing //关闭terminal 的编辑功能 Router#terminal editing 3、基本IOS 命令 先连接到R1 路由器上: Router>enable Router#configure terminal Router(config)#hostname R1 //改变路由器的名称为“R1”,设置立即生效。 R1(config)#enable password cisco //改变了enable 的密码为“cisco”,这个密码是从用户模式进入到特权模式的密码。 R1(config)#interface g0/0 //进入到接口模式,这里是千兆以太网口(第0 个插槽的第0 个接口,编号从0 开始)。 R1(config-if)#ip address 10.1.1.1 255.255.255.0 //给以太接口配置一个IP 地址10.1.1.1,掩码为255.255.255.0 。 R1(config-if)#no shutdown //开启以太网口,因为默认时路由器的各个接口是关闭的。 R1(config-if)#exit //退回到上一级模式 R1(config)#interface s0/0/0 //进入到接口模式,这里是串行接口 R1(config-if)#ip address 10.12.12.1 255.255.255.0 //给串行接口配置一个IP 地址 R1(config-if)#no shutdown //开启接口 R1(config-if)#end(或【Ctrl+Z】) //结束配置直接回到特权模式下。 R1#copy running-config startup-config //把内存中的配置保存到NVRAM 中,路由器开机时会读取它。 Destination filename [startup-config]? Building configuration... [OK] 4、连接到R2 路由器上,进行以下操作: Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R2 R2(config)#enable password cisco R2(config)#interface g0/0 R2(config-if)#ip address 10.2.2.2 255.255.255.0 R2(config-if)#no shutdown R2(config-if)#exit R2(config)#interface s0/0/0 R2(config-if)#ip address 10.12.12.2 255.255.255.0 R2(config-if)#clock rate 128000 //R2 这一端是DCE,需要配置时钟 R2(config-if)#no shutdown R2(config-if)#end R2#copy running-config startup-config R2#ping 10.12.12.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.14.126, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms //从R2 ping R1 的串行接口,可以ping 通 本文转自1594cqb 51CTO博客,原文链接:http://blog.51cto.com/wolfchen/1088673,如需转载请自行联系原作者

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

Android学习笔记--Android开发时常用控件(一)

MicrosoftInternetExplorer402DocumentNotSpecified7.8Normal0 TextView,Button,EditText,Menu 例,实现一个简单的计算器功能 实现过程一1.在第一个Activity中,声明4个控件(2个编辑框,1个文本域,1个按钮) 2.要为其中的两个空间设置显示的值(文本域和按钮) 3.创建一个监听器.监听按钮事件 4.将监听器对象绑定到按钮对象上 在布局的xml文件中添加控件例: <EditText Android:id="@+id/eText1" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> <TextView Android:id="@+id/tView" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> <EditText Android:id="@+id/eText2" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> <Button Android:id="@+id/bBtn" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> 在使用空间的Activity页面中取出控件 例:publicclassActivityextendsActivity{ PrivateEditTexteText1; PrivateEditTexteText2; PrivateTextViewtView; PriveteButtonbBtn; @override PublicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); //根据控件的ID来取得代表控件的对象 eText1=(EditText)findViewById(R.id.eText1); eText2=(EditText)findViewById(R.id.eText2); tView=(TextView)findViewById(R.id.tView); tView,setText("乘以"); bBtn=(Button)findViewById(R.id.bBtn); bBtn.setText("计算");//为button设置值 //或设置在res/strings.xml中设置 //例:<stringname="bBtnText">计算</string> //bBtn.setText(R.string.bBtnText); //将监听器对象绑定按钮对象上去 bBtn.setOnClickLinstrener(newCalculateListener()); } //内部类监听器 ClassCalculateListenerimplementsOnClickListener{ @Override PublicvoidonClick(Viewv){ //取得两个编辑框的值 StringeText1=eText1.getText().toString(); StringeText2=eText2.getText().toString(); //将两个值放入到Intent对象之中 Intentintent=newIntent(); //使用这个Intent对象启动下一个Activity intent.putExtra("one",eText1); intent.putExtra("two",eText2); intent.setClass(Activity.this,ResultActivity.class); Activity.this.startActivity(intent); } } } 实现过程第二步: 1.接受从Activity当中传递的值 2.计算两个值的积 3.将计算的结果显示在当前的Activity中 //在当前的Activity中的xml文件中添加一个文本域 <TextView Android:id="@+id/tViewResult" Android:layout_width="fill_parent" Android:layout_height="wrap_content" /> 在onCreate中执行语句(不再累赘) 关键代码://取到RestltView的对象 Intentintent=getIntent(); StringtText1=intnet.getStringExtra("one"); StringtText2=intnet.getStringExtra("two"); InttText1int=Integer.parseInt(tText1); InttText2int=Integer.parseInt(tText2); Intresult=tText1int*tText2int; RestltView.setText(result+""); Menu对象的实现 复写函数onCreateOptionMenu() PublicbooleanonCreateOptionMenu(Menumenu){ //第二个参数就是itemid Menu.add(0,1,1,R.string.exit); Menu.add(0,2,2,R.string.about); Returnsuper.onCreate } 继续实现menuitem的事件方法 //当用户点击菜单的某一选项时,会调用该方法 复写onOPtionsItemSelected(MenuItemitem); PublicbooleanonOPtionsItemSelected(MenuItemitem){ If(item.getItemId()==1){ Finish(); } Returnsuper.onOptionsItemSelected(MenuItemitem); } 本文转自My_King1 51CTO博客,原文链接:http://blog.51cto.com/apprentice/1360577,如需转载请自行联系原作者

资源下载

更多资源
腾讯云软件源

腾讯云软件源

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

Spring

Spring

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

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

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

用户登录
用户注册