首页 文章 精选 留言 我的

精选列表

搜索[网站开发],共10000篇文章
优秀的个人博客,低调大师

Android开发学习笔记:浅谈ToggleButton

ToggleButton(开关按钮)是Android系统中比较简单的一个组件,是一个具有选中和未选择状态双状态的按钮,并且需要为不同的状态设置不同的显示文本。 ToggleButton常用的XML属性 属性名称 描述 android:disabledAlpha 设置按钮在禁用时透明度。 android:textOff 未选中时按钮的文本 android:textOn 选中时按钮的文本 下面是具体的例子: 第一个例子是通过Toast显示ToggleButton不同的状态时的信息 MainActivity.java packagecom.android.togglebutton; importandroid.app.Activity; importandroid.os.Bundle; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Toast; importandroid.widget.ToggleButton; publicclassMainActivityextendsActivity{ //声明ToggleButton privateToggleButtontogglebutton; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); togglebutton=(ToggleButton)findViewById(R.id.togglebutton); togglebutton.setOnClickListener(newOnClickListener(){ publicvoidonClick(Viewv){ //当按钮第一次被点击时候响应的事件 if(togglebutton.isChecked()){ Toast.makeText(MainActivity.this,"你喜欢球类运动",Toast.LENGTH_SHORT).show(); } //当按钮再次被点击时候响应的事件 else{ Toast.makeText(MainActivity.this,"你不喜欢球类运动",Toast.LENGTH_SHORT).show(); } } }); } } main.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <ToggleButton android:id="@+id/togglebutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOn="喜欢" android:textOff="不喜欢" /> </LinearLayout> strings.xml <?xmlversion="1.0"encoding="utf-8"?> <resources> <stringname="hello">你喜不喜欢球类运动?</string> <stringname="app_name">测试ToggleButton</string> </resources> 效果图: 第二个例子通过图片的变化显示ToggleButton不同的状态时的图片 MainActivity.java packagecom.android.togglebutton; importandroid.app.Activity; importandroid.os.Bundle; importandroid.widget.CompoundButton; importandroid.widget.CompoundButton.OnCheckedChangeListener; importandroid.widget.ImageView; importandroid.widget.ToggleButton; publicclassMainActivityextendsActivity{ //声明ImageView,ToggleButton privateImageViewimageView; privateToggleButtontoggleButton; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); //通过findViewById获得ImageView,ToggleButton imageView=(ImageView)findViewById(R.id.imageView); toggleButton=(ToggleButton)findViewById(R.id.toggleButton); toggleButton.setOnCheckedChangeListener(newOnCheckedChangeListener(){ publicvoidonCheckedChanged(CompoundButtonbuttonView,booleanisChecked){ toggleButton.setChecked(isChecked); //使用三目运算符来响应按钮变换的事件 imageView.setImageResource(isChecked?R.drawable.pic_on:R.drawable.pic_off); } }); } } main.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/pic_off" android:layout_gravity="center_horizontal" /> <ToggleButton android:id="@+id/toggleButton" android:layout_width="130dip" android:layout_height="wrap_content" android:textOn="开灯" android:textOff="关灯" android:layout_gravity="center_horizontal" /> </LinearLayout> 效果图: 本文转自 lingdududu 51CTO博客,原文链接:http://blog.51cto.com/liangruijun/655014

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

Android开发学习笔记:浅谈Toast

一.Toast的简介 Toast是Android中一种提供给用户简短信息的视图,该视图已浮于应用程序之上的形式呈现给用户。因为它并不获得焦点,即使用户正在输入什么也不会受到影响。它的目标是尽可能已不显眼的方式,使用户看到你提供的信息。显示的时间是有限制的,过一段时间后会自动消失,不过Toast本身可以控制显示时间的长短。 二.Toast的常用方法 int getDuration() 返回Toast视图显示持续的时间. int getGravity() 取得提示信息在屏幕上显示的位置. float getHorizontalMargin() 返回横向栏外空白 float getVerticalMargin() 返回纵向栏外空白. View getView() 返回View对象. int getXOffset() 返回相对于参照位置的横向偏移像素量。 int getYOffset() 返回相对于参照位置的纵向偏移像素量 staticToast makeText(Contextcontext, int resId, int duration) 生成一个从资源中取得的包含文本视图的标准Toast对象。 context使用的上下文。通常是你的Application或Activity对象 resId要使用的字符串资源ID,可以是已格式化文本。 duration该信息的存续期间。值为LENGTH_SHORT或LENGTH_LONG staticToast makeText(Contextcontext,CharSequencetext, int duration) 生成一个包含文本视图的标准Toast对象. void setDuration(int duration) 设置Toast视图显示持续的时间,LENGTH_LONG表示持续时间较长,LENGTH_SHORT表示持续时间较短 void setGravity(int gravity, int xOffset, int yOffset) 设置提示信息在屏幕上的显示位置.(自定义Toast的显示位置,例如toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0)可以把Toast定位在左上角。Toast提示的位置xOffset:大于0向右移,小于0向左移) void setMargin(float horizontalMargin, float verticalMargin) 设置视图的栏外空白. horizontalMargin容器的边缘与提示信息的横向空白(与容器宽度的比) verticalMargin容器的边缘与提示信息的纵向空白(与容器高度的比)。 void setText(int resId) 更新之前通过makeText()方法生成的Toast对象的文本内容.resId为Toast指定的新的字符串资源ID。 void setText(CharSequences) 更新之前通过makeText()方法生成的Toast对象的文本内容. s为Toast指定的新的文本 void setView(Viewview) 设置要显示的View.注意这个方法可以显示自定义的toast视图,可以包含图像,文字等等。是比较常用的方法 void show() 按照指定的存续期间显示提示信息 三.Toast的不同显示样式 效果图(有五种不同的Toast显示样式): main.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/btn_1" android:text="@string/btn1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btn_2" android:text="@string/btn2" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btn_3" android:text="@string/btn3" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btn_4" android:text="@string/btn4" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/btn_5" android:text="@string/btn5" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> toast.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" android:background="#708090" > <ImageView android:id="@+id/img" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="带图片文字的Toast" /> </LinearLayout> strings.xml <?xmlversion="1.0"encoding="utf-8"?> <resources> <stringname="hello">HelloToast!</string> <stringname="app_name">ToastDemo</string> <stringname="btn1">系统默认的Toast</string> <stringname="btn2">自定义位置的Toast</string> <stringname="btn3">带只有图片的Toast</string> <stringname="btn4">有图有文字的Toast</string> <stringname="btn5">自定义布局的Toast</string> </resources> ToastDemoActivity.java packagecom.android.toast.activity; importandroid.app.Activity; importandroid.content.Context; importandroid.os.Bundle; importandroid.view.Gravity; importandroid.view.LayoutInflater; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; importandroid.widget.ImageView; importandroid.widget.LinearLayout; importandroid.widget.Toast; publicclassToastDemoActivityextendsActivity{ privateButtonbtn_1,btn_2,btn_3,btn_4,btn_5; privateToasttoast=null; @Override protectedvoidonCreate(BundlesavedInstanceState){ //TODOAuto-generatedmethodstub super.onCreate(savedInstanceState); setContentView(R.layout.main); btn_1=(Button)findViewById(R.id.btn_1); btn_2=(Button)findViewById(R.id.btn_2); btn_3=(Button)findViewById(R.id.btn_3); btn_4=(Button)findViewById(R.id.btn_4); btn_5=(Button)findViewById(R.id.btn_5); btn_1.setOnClickListener(newButtonClick()); btn_2.setOnClickListener(newButtonClick()); btn_3.setOnClickListener(newButtonClick()); btn_4.setOnClickListener(newButtonClick()); btn_5.setOnClickListener(newButtonClick()); } classButtonClickimplementsOnClickListener{ @Override publicvoidonClick(Viewv){ //TODOAuto-generatedmethodstub switch(v.getId()){ caseR.id.btn_1: toast.makeText(ToastDemoActivity.this,"默认的Toast显示",Toast.LENGTH_LONG).show(); break; caseR.id.btn_2: //getApplicationContext()得到程序当前的默认Context toast=Toast.makeText(getApplicationContext(),"自定义位置的Toast显示", Toast.LENGTH_LONG); //设置Toast的位置 toast.setGravity(Gravity.CENTER,toast.getXOffset()/2,toast.getYOffset()/2); toast.show(); break; caseR.id.btn_3: toast=Toast.makeText(getApplicationContext(),"只有图片的Toast显示", Toast.LENGTH_LONG); ImageViewimg=newImageView(ToastDemoActivity.this); img.setImageResource(R.drawable.android); toast.setView(img); toast.show(); break; caseR.id.btn_4: toast=Toast.makeText(getApplicationContext(),"有图有字的Toast",Toast.LENGTH_LONG); LinearLayoutlayout=(LinearLayout)toast.getView(); ImageViewimg1=newImageView(getApplicationContext()); img1.setImageResource(R.drawable.android); layout.addView(img1,0); toast.show(); break; caseR.id.btn_5: //将一个xml布局转换成一个view对象 LayoutInflaterinflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); Viewview=inflater.inflate(R.layout.toast,null); Toasttoast=newToast(getApplicationContext()); //在view中查找查找ImageView控件 ImageViewimage=(ImageView)view.findViewById(R.id.img); image.setImageResource(R.drawable.android); toast.setView(view); toast.show(); break; default: break; } } } } 本文转自 lingdududu 51CTO博客,原文链接: http://blog.51cto.com/liangruijun/638913

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

Android开发之adb无法连接

2017/11/14 21:20 Unable to run 'adb': null 21:20 'E:\AndroidSDK\platform-tools\adb.exe start-server' failed -- run manually if necessary 21:20 error: cannot open transport registration socketpair: Invalid argument 21:20 This application has requested the Runtime to terminate it in an unusual way. 21:20 Please contact the application's support team for more information. 21:20 could not read ok from ADB Server 21:20 * failed to start daemon * 21:20 error: cannot connect to daemon 2017/11/14 21:20 Unable to run 'adb': null 21:20 'E:\AndroidSDK\platform-tools\adb.exe start-server' failed -- run manually if necessary 21:20 error: cannot open transport registration socketpair: Invalid argument 21:20 This application has requested the Runtime to terminate it in an unusual way. 21:20 Please contact the application's support team for more information. 21:20 could not read ok from ADB Server 21:20 * failed to start daemon * 21:20 error: cannot connect to daemon adb无法连接,出现如上日志文件 解决方法: windows 10环境下关闭防火墙即可

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

【移动开发】WIFI热点通信(一)

之前调查过Android中WIFI模块的使用,也写过两篇学习总结的文章(http://smallwoniu.blog.51cto.com/3911954/1334951),后来发现DEMO里面还是有许多不足之处,前段时间有不少人Q我,问到WIFI模块中的一些细节,小弟这里只能说声抱歉,因为当时的我也还没研究到那个层次呀。。。,后来毕业设计选题干脆直接选择了关于WIFI热点通信方面的题目,调查和整理了一些资料,进行了一段时间的学习算是弥补了自己的短板吧,主要还是希望自己能够更加全面的掌握这方面的知识。 废话不多说了!今天主要讲解WIFI热点通信的前期准备工作: 1.热点创建:创建指定名称的热点。 2.热点搜索:搜索附近可用热点,生成列表。 3.热点连接:在列表中点击指定名称的WIFI项,进行连接操作。 一.框架搭建 说明: 1.几个权限: 1 2 3 4 5 6 < uses-permission android:name = "android.permission.INTERNET" /> < uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" /> < uses-permission android:name = "android.permission.CHANGE_NETWORK_STATE" /> < uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" /> < uses-permission android:name = "android.permission.CHANGE_WIFI_STATE" /> < uses-permission android:name = "android.permission.WAKE_LOCK" /> 2.相关类图: 二.模块讲解 接下来通过以下三个部分功能来逐一剖析,在此之前首先看一张最终的效果图加深以下印象: (由于本章讲解的部分是我的整个项目中的一部分,所以大家不用在意图片素材等其他细节) 2.1热点创建 点击WIFI管理界面中创建热点按钮,首先会检测当前WIFI是否可用,若可用则需将其关闭掉才能创建WIFI热点,因为手机热点把手机的接收GPRS或3G信号转化为WIFI信号再发出去,即你的手机就成了一个WIFI热点,所以共享和接收功能是不能同时进行的。之后就是创建指定名称的热点过程。热点创建时序图如下图所示。 几个核心方法: startApWifiHot() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 /** *createahotwifi * *@paramwifiName */ public boolean startApWifiHot(StringwifiName){ Log.i(TAG, "intostartApWifiHot(StringwifiName)wifiName=" +wifiName); if (wifiManager.isWifiEnabled()){ wifiManager.setWifiEnabled( false ); } if (mWifiHotAdmin!= null ){ return mWifiHotAdmin.startWifiAp(wifiName); } Log.i(TAG, "outstartApWifiHot(StringwifiName)" ); return false ; } createWifiAp() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 /** *starthotpot *@paramwifiName *@return */ private boolean createWifiAp(StringwifiName){ Log.i(TAG, "intostartWifiAp()启动一个Wifi热点!" ); Methodmethod1= null ; boolean ret= false ; try { //setWifiApEnabledis@hide,soreflect method1=mWifiManager.getClass().getMethod( "setWifiApEnabled" , WifiConfiguration. class , boolean . class ); WifiConfigurationapConfig=createPassHotWifiConfig(wifiName,Global.PASSWORD); ret=(Boolean)method1.invoke(mWifiManager,apConfig, true ); } catch (IllegalArgumentExceptione){ e.printStackTrace(); Log.d(TAG, "stratWifiAp()IllegalArgumentExceptione" ); } Log.i(TAG, "outstartWifiAp()启动一个Wifi热点!" ); return ret; } 2.2热点搜索 点击WIFI管理界面中搜索热点按钮,同创建一样,首先需要检测WIFI热点是否关闭,将其关闭掉后才能打开WIFI搜索功能。在搜索完成后系统会发送WIFI状态变化广播来通知消息栏,这里通过自定义广播接收器接收了搜索成功消息,最后通过回调MainActivity中disPlayWifiScanResult()来显示WIFI列表。 几个核心方法: scanWifiHot() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 /**scanwifihot**/ public void scanWifiHot(){ Log.i(TAG, "intowifiHotScan()" ); if (mWifiHotAdmin.isWifiApEnabled(wifiManager)){ mWifiHotAdmin.closeWifiAp(); } if (!wifiIsOpen()){ //WIFIisclosecurrently //listentothespecifiedSSIDwifistate registerWifiStateBroadcast( "" ); mWifiStateReceiver.setOperationsType(OperationsType.SCAN); //openwifi openWifi(); } else { //WIFIisopencurrently scanNearWifiHots(); } Log.i(TAG, "outwifiHotScan()" ); } scanNearWifiHots() 1 2 3 4 5 6 /**scannearwifi**/ private void scanNearWifiHots(){ registerWifiScanBroadcast(); //startscan wifiManager.startScan(); } 说明:这里的扫描实现过程是通过调用系统中WifiManager中扫描功能。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 /** *Requestascanforaccesspoints.Returnsimmediately.Theavailability *oftheresultsismadeknownlaterbymeansofanasynchronouseventsent *oncompletionofthescan. *@return{@codetrue}iftheoperationsucceeded,i.e.,thescanwasinitiated */ public boolean startScan(){ try { mService.startScan( false ); return true ; } catch (RemoteExceptione){ return false ; } } 2.3热点连接 在搜索完成之后,需要在WIFI列表中找到游戏的热点,点击连接过程会处理一系列逻辑:当前WIFI可用、是否已经连接、注册WIFI状态变化广播等,之后,开启独立线程进行热点匹配连接,热点连接时序图如图所示。 几个核心方法: connectToHotpot() 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 /** *connecttohotpot * *@paramssid *@paramwifiList *@parampassword */ public void connectToHotpot(Stringssid,List<ScanResult>wifiList,Stringpassword){ if (ssid== null ||password.equals( "" )||!ssid.equals(Global.HOTPOT_NAME)){ Log.d(TAG, "WIFIssidisnullor" ); mWifiBroadCastOperator.disPlayWifiConnResult( false , null ); return ; } if (ssid.equalsIgnoreCase(mSSID)&&isConnecting){ Log.d(TAG, "samessidisconnecting!" ); mWifiBroadCastOperator.disPlayWifiConnResult( false , null ); return ; } if (!checkCoonectHotIsEnable(ssid,wifiList)){ Log.d(TAG, "ssidisnotinthewifiList!" ); mWifiBroadCastOperator.disPlayWifiConnResult( false , null ); return ; } if (!wifiIsOpen()){ //listentossidwifi registerWifiStateBroadcast(ssid); mWifiStateReceiver.setOperationsType(OperationsType.CONNECT); //openwifi openWifi(); } else { //realconnecting enableNetwork(ssid,password); } } enableNetwork() 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 /** *connectwifihotreallybythread * *@paramssid *@parampassword */ private void enableNetwork( final Stringssid, final Stringpassword){ //deletemoreconnetedwifi deleteMoreCon(ssid); registerWifiConnectBroadCast(); new Thread( new Runnable(){ @Override public void run(){ WifiConfigurationconfig=WifiHotConfigAdmin.createWifiNoPassInfo(ssid,password); //ifconnectissuccessful isConnecting=connectHotSpot(config); mSSID=ssid; if (!isConnecting){ Log.i(TAG, "intoenableNetwork(WifiConfigurationwifiConfig)isConnecting=" +isConnecting); return ; } } }).start(); } connectHotSpot() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 /** *connectwifihotifsuccessful * *@paramwifiConfig *@return */ private boolean connectHotSpot(WifiConfigurationwifiConfig){ Log.i(TAG, "intoenableNetwork(WifiConfigurationwifiConfig)" ); //theIDofthenewlycreatednetworkdescription int wcgID=wifiManager.addNetwork(wifiConfig); Log.i(TAG, "intoenableNetwork(WifiConfigurationwifiConfig)wcID=" +wcgID); if (wcgID< 0 ){ return false ; } boolean flag=wifiManager.enableNetwork(wcgID, true ); Log.i(TAG, "outenableNetwork(WifiConfigurationwifiConfig)" ); return flag; } 说明:连接热点的过程实质上就是获取热点配置信息,之后将其添加到自己的网络信息中同时使其可用。 至此,WIFI热点通信的前期工作已经完成,连接的手机端已在同一局域网内,若再有手机连接进来会自动为其分配该网段内的IP地址,接下来我们要做的就是在IP地址上实现数据的传输通信。在下一章中准备实现一个多人聊天室功能,希望能够帮助到大家! 源码下载:http://down.51cto.com/data/1812897 本文转自zhf651555765 51CTO博客,原文链接:http://blog.51cto.com/smallwoniu/1536126,如需转载请自行联系原作者

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

openstack nova 开发 CURL list 记录

CURL list [ -------------------------------- ] 1, delete nova.network curl -v -X DELETE -H 'X-Auth-Token: d7f3d029deb54a7fa354b3ded882150a' -H 'X-Tenant-Id: 842748637c7c419a9af9e787350aca6b' -H 'X-User-Id: ea15fa0ea7034fb89fa991585aca9325' -H "Content-type: application/json" http://0.0.0.0:8774/v2/842748637c7c419a9af9e787350aca6b/vpdc_networks/f35f6419-1a76-4b8a-b985-b2595b49338a | python -mjson.tool 2, create nova.network (vlan100 模式) curl -v -X POST -H 'X-Auth-Token: d3ba55778f4745e4804c2e7689669d49' -H 'X-Tenant-Id: 842748637c7c419a9af9e787350aca6b' -H 'X-User-Id: e745ac0e1c594895991a34bc92c939fc' -H "Content-type: application/json" -d '{"network": { "label": "lan", "vlan": 100, "dns1": "114.114.114.114", "dns2": "8.8.8.8", "vlan_start":100, "security_lan_id":123, "network_size":62, "dhcp_enabled": true }}'http://0.0.0.0:8774/v2/842748637c7c419a9af9e787350aca6b/***_networks 2, create nova.network (FlatDHCPManager 模式) curl -v -X POST -H 'X-Auth-Token: 9fb501eee04842b3bc232bac65d20942' -H 'X-Tenant-Id: 842748637c7c419a9af9e787350aca6b' -H 'X-User-Id: e745ac0e1c594895991a34bc92c939fc' -H "Content-type: application/json" -d '{"network": { "label": "lan", "vlan": 100, "dns1": "114.114.114.114", "dns2": "8.8.8.8", "security_lan_id":123, "network_size":62, "dhcp_enabled": true }}' http://0.0.0.0:8774/v2/842748637c7c419a9af9e787350aca6b/***_networks 3, show nova.network curl -v -X GET -H 'X-Auth-Token: d7f3d029deb54a7fa354b3ded882150a' -H 'X-Tenant-Id: 842748637c7c419a9af9e787350aca6b' -H 'X-User-Id: ea15fa0ea7034fb89fa991585aca9325' -H "Content-type: application/json" http://0.0.0.0:8774/v2/842748637c7c419a9af9e787350aca6b/vpdc_networks/f35f6419-1a76-4b8a-b985-b2595b49338a | python -mjson.tool 4, history_monitor nova.api curl -v -d '{historyControl: {hN:HSCloudNode001, iT:cpu,sT:1377672552.412417, eT:1377673544.507965}}' -i http://127.0.0.1:8774/v2/842748637c7c419a9af9e787350aca6b/wqservers/1/action -X POST -H X-Auth-Project-Id: 842748637c7c419a9af9e787350aca6b -H Accept: application/json -H X-Auth-Token: 6740bb82db184190b5b90ff0d23203b9 -H Content-Type: application/json 4, 获取token ID, curl -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "admin"}}}' -H "Content-type: application/json" http://127.0.0.1:35357/v2.0/tokens | python -m json.tool 5, ioctl nova.compute curl -v -d '{"ioControl": {"instance_name":"instance-0000000d","limit_size":"50MB"}}' -i http://127.0.0.1:8774/v2/842748637c7c419a9af9e787350aca6b/servers/59d83dc5-3cfe-4488-b62e-1d338445457a/action -X POST -H "X-Auth-Project-Id: 842748637c7c419a9af9e787350aca6b" -H "Accept: application/json" -H "X-Auth-Token: f406297155a24bffb9a52aa9da5b3e89" -H "Content-Type: application/json" 本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1298829

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

openstack API 开发 - 关于获取token

1, 获取token curl -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "admin"}}}' -H "Content-type: application/json" http://127.0.0.1:35357/v2.0/tokens | python -m json.tool 2,根据token,发送API请求 curl -v -d '{"migrate2": {"force_hosts":"hostname"}}' -i http://127.0.0.1:8774/v2/{project_id}/servers/{vm_uuid}/action -X POST -H "X-Auth-Project-Id: {project_id}" -H "Accept: application/json" -H "X-Auth-Token: {token_id}" -H "Content-Type: application/json" 3,实例 curl -v -d '{"ioControl": {"instance_name":"instance-0000000d","limit_size":"50MB"}}' -i http://127.0.0.1:8774/v2/842748637c7c419a9af9e787350aca6b/servers/59d83dc5-3cfe-4488-b62e-1d338445457a/action -X POST -H "X-Auth-Project-Id: 842748637c7c419a9af9e787350aca6b" -H "Accept: application/json" -H "X-Auth-Token: f406297155a24bffb9a52aa9da5b3e89" -H "Content-Type: application/json" 本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1255933

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

Android GIS开发系列计划

本系列博客的整理与写作计划如下,计划3个月(至2018.2)完成。 第一部分, 入门季 第二部分, Android基础季 第三部分, Data Flow 季 第四部分, 可视化季 第五部分, GIS常见应用季 第六部分, GIS算法季 第七部分, GIS工程应用案例季 第八部分, 学术季 其中,第一季中的15篇文章的粗略的内容,已借鉴网络某系列博客的原始内容,尚未加工处理与改善,计划17年12月中旬之前完成初稿。 没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。 本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/7757495.html ,如需转载请自行联系原作者

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

Windows 搭建Hadoop 2.7.3开发环境

1、安装配置Java环境 1.1、安装Windows版本的jkd应用程序 当前的系统环境是64位Windows 7,因此下载64位JDK,下载地址:http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-windows-x64.exe 下载后直接点击安装,默认的安装位置为:C:\Java\jdk 1.2、配置Java环境变量 鼠标右键 "我的电脑"-->"属性" 点击左边 "高级系统设置"-->"环境变量" 增加JAVA_HOME变量,在系统变量点击 "新建" 变量:JAVA_HOME 变量值:C:\Java\jdk 在path上增加java安装路径,找到path点击"编辑" 在最后增加:;%JAVA_HOME%\bin;%JAVA_HOME%\lib;%JAVA_HOME%\jre\bin 增加CLASSPATH 变量:CLASSPATH 变量值:%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar java的环境变量设置完成后,在命令提示符输入命令检查:java -version 如果输出java信息说明环境设置完成; 2、安装配置Hadoop 2.1、下载安装Hadoop 下载Hadoop 2.7.3,下载地址:找到2.7.3版本,下载hadoop-2.7.3.tar.gz 将下载的hadoop-2.7.3.tar.gz解压移动到:C:\Usr\local\ 2.2、配置Hadoop 2.2.1、配置Hadoop环境变量 配置Hadoop环境变量:HADOOP_HOME,方法参照java 新建HADOOP_CONF_DIR变量:变量值:%HADOOP_HOME%\etc\hadoop 新建YARN_CONF_DIR变量:变量值:%HADOOP_CONF_DIR% 配置Hadoop path变量:%HADOOP_HOME%/bin 2.2.2、配置Hadoop配置文件 Hadoop配置文件存放在:C:\Usr\local\hadoop-2.7.3\etc\hadoop,在C:\Usr\local\hadoop-2.7.3目录下创建文件夹hdfs/{datanode,namenode} 2.2.2.1、 配置core-site.xml <configuration> <property> <name>fs.defaultFS</name> <value>hdfs://localhost:9000</value> </property> </configuration> 2.2.2.2、 配置hdfs-site.xml <configuration> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>/C:/Usr\local/hadoop-2.7.3/hdfs/namenode</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>/C:/Usr/local/hadoop-2.7.3/hdfs/datanode</value> </property> </configuration> 2.2.2.3、 配置mapred-site.xml <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration> 2.2.2.4、 配置yarn-site.xml <configuration> <!-- Site specific YARN configuration properties --> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name> <value>org.apache.hadoop.mapred.ShuffleHandler</value> </property </configuration> 2.2.2.5、 配置slaves localhost 2.2.2.6、 配置hadoop-env.cmd 将JAVA_HOME修改为:set JAVA_HOME=C:\PROGRA~1\Java\jdk1.8.0_131并在后面追加如下设置: set HADOOP_IDENT_STRING=%USERNAME% set HADOOP_PREFIX=C:\Usr\local\hadoop-2.7.3 set HADOOP_CONF_DIR=%HADOOP_PREFIX%\etc\hadoop set YARN_CONF_DIR=%HADOOP_CONF_DIR% set PATH=%PATH%;%HADOOP_PREFIX%\bin 注:C:\PROGRA~1用于替代C:\Program Files 2.3、替换Hadoop windows可执行程序 下载winutils相关,hadoop在windows上运行需要winutils支持和hadoop.dll等文件。下载地址下载对应版本的就可以,例如我用的是2.7.3,可以直接下载2.7.1的就好。然后把winutils.exe和hadoop.dll复制到hadoop的bin目录下; 2.4、启动Hadoop 1.格式化HDFS 打开cmd cd c:\usr\local\hadoop-2.7.3\bin hdfs namenode -format 2.启动Hadoop 打开cmd cd c:\usr\local\hadoop-2.7.3\sbin start-all.cmd YARN管理界面:http://localhost:8088 HDFS管理界面:http://localhost:50070 3.简单的HDFS操作 查看信息:hadoop fs -ls hdfs://localhost:9000/ 创建目录: · hadoop fs -lmkdir hdfs://localhost:9000/user/wc· 上传文件:hadoop fs -put C:\Usr\local\hadoop\LICENSE.txt hdfs://localhost:9000/user/wc 本文转自 巴利奇 51CTO博客,原文链接:http://blog.51cto.com/balich/2058194

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

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

Rocky Linux

Rocky Linux

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

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册