到搜灵首页

您查询的关键词仅在网页标题或指向此网页的链接中出现。

(搜灵和网页http://www.fuckbe.net/csz/c21591_488770.html的作者无关,不对其内容负责。搜灵快照谨为网络故障时之索引,不代表被搜索网站的即时页面。)


鍒╃敤Handler瀹氭椂鏇存柊Android UI_鐢靛奖澶╁爞

妫案濂堢窉缇

闄堢窘鍑$煶鏅北灏忓尯-鍒╃敤Handler瀹氭椂鏇存柊Android UI

鍦 Android 閲屽畾鏃舵洿鏂 UI锛岄氬父浣跨敤鐨勬槸 java.util.Timer, java.util.TimerTask, android.os.Handler 缁勫悎锛岃繖閲屾湁鐩稿叧鐨勮璁恒備絾瀹為檯涓 Handler 鑷韩宸茬粡鎻愪緵浜嗗畾鏃剁殑鍔熻兘銆
 
鍙傝 android.os.Handler 鐨勬枃妗

寮曠敤

 
There are two main uses for a Handler: (1) to schedule messages and runnables to be executed as some point in the future; and (2) to enqueue an action to be performed on a different thread than your own.

Scheduling messages is accomplished with the post(Runnable), postAtTime(Runnable, long), postDelayed(Runnable, long), sendEmptyMessage(int), sendMessage(Message), sendMessageAtTime(Message, long), and sendMessageDelayed(Message, long) methods. The post versions allow you to enqueue Runnable objects to be called by the message queue when they are received; the sendMessage versions allow you to enqueue a Message object containing a bundle of data that will be processed by the Handler's handleMessage(Message) method (requiring that you implement a subclass of Handler).
 

When posting or sending to a Handler, you can either allow the item to be processed as soon as the message queue is ready to do so, or specify a delay before it gets processed or absolute time for it to be processed. The latter two allow you to implement timeouts, ticks, and other timing-based behavior銆

涓嬮潰鏄竴涓畝鍗曠殑璁℃暟鍣ㄧ▼搴忥紝姣忛殧涓绉掗掑璁℃暟鍣

浠g爜

main.xml

<?xml version="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">
 <TextView android:id="@+id/counter" android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:text="Count: 0" />
 <LinearLayout android:orientation="horizontal"
  android:layout_width="fill_parent" android:layout_height="wrap_content">
  <Button android:text="start" android:id="@+id/Button01"
   android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0"></Button>
  <Button android:text="stop" android:id="@+id/Button02"
   android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:enabled="false"></Button>
  <Button android:text="reset" android:id="@+id/Button03"
   android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0"></Button>
 </LinearLayout>
</LinearLayout>

褰撳墠鏂囩珷锛歨ttp://www.fuckbe.net/csz/c21591_488770.html

鍙戝竷鏃堕棿锛08:14:03

PHP鐩掑瓙  Jiacrontab  Jiacrontab  Jiacrontab  Jiacrontab  Jiacrontab  Jiacrontab  Jiacrontab  Jiacrontab  Jiacrontab  Jiacrontab  

{鐩稿叧鏂囩珷}

Tomcat閮ㄧ讲Web搴旂敤

1銆佺洿鎺ユ斁鍒癢eb鍑虹杞︿笂鎵撳箍鍛婂垬鍊鐢靛奖澶╁爞apps鐩棰嗗彇鍏昏佷繚闄╃殑閫浼戝勾榫刜鐢靛奖澶╁爞褰曚笅

    Tomcat鐨刉ebapps鐩綍鏄疶omcat榛樿鐨勫簲鐢ㄧ洰褰曪紝褰撴湇鍔″櫒鍚姩鏃讹紝浼氬姞杞芥墍鏈夎繖涓洰褰曚笅鐨勫簲鐢ㄣ備篃鍙互灏咼SP绋嬪簭鎵撳寘鎴愪竴涓滅殗澶竴閫愭ⅵ涔嬪厜_鐢靛奖澶╁爞涓獁ar鍖呮斁鍦ㄧ洰褰曚笅锛屾湇鍔″櫒浼氳嚜鍔ㄨВ寮杩欎釜war鍖咃紝骞跺湪杩欎釜鐩綍涓嬬敓鎴愪竴涓悓鍚嶇殑鏂囦欢澶广備竴涓獁ar鍖呭氨鏄湁鐗规ф牸寮忕殑jar鍖咃紝瀹冩槸灏嗕竴涓猈eb绋嬪簭鐨勬墍鏈夊唴瀹硅繘琛屽帇缂╁緱鍒般傚叿浣撳浣曟墦鍖咃紝鍙互浣跨敤璁稿寮鍙戝伐鍏风殑IDE鐜锛屽Eclipse銆丯etBeans銆乤nt銆丣Builder绛夈備篃鍙互鐢╟md 鍛戒护锛歫ar -cvf applicationname.war package.*锛

鐢氳嚦鍙互鍦ㄧ▼搴忔墽琛屼腑鎵撳寘锛

try{  

  string strjavahome =system.getproperty("java.home"); 

  strjavahome =strjavahome.substring(0,strjavahome.lastindexof(\\))+"\\bin\\";  

  runtime.getruntime().exec("cmd /c start"+strjavahome+"jar cvf hello.warc:\\tomcat5.0\\webapps\\root\\*"); 

  }  

catch(exception   e){system.out.println(e);}

 

    webapps杩欎釜榛樿鐨勫簲鐢ㄧ洰褰曚篃鏄彲浠ユ敼鍙樸傛墦寮Tomcat鐨刢onf鐩綍涓嬬殑server.xml鏂囦欢锛屾壘鍒颁笅闈㈠唴瀹癸細

<Hostname="localhost" debug="0" appBase="webapps"unpackWARs="true" autoDeloy="true" xmlVal濂冲瓙閰嶄箰楝煎瓙杩涙潙闊充箰_鐢靛奖澶╁爞idation="falase"xmlNamespaceAware="false">

 

2銆佸湪server.xml涓寚瀹

    鍦═omcat鐨勯厤缃枃浠朵腑锛屼竴涓猈eb搴旂敤灏辨槸涓涓壒瀹氱殑Context锛屽彲浠ラ氳繃鍦╯erver.xml涓柊寤篊ontext閲岄儴缃蹭竴涓狫SP搴旂敤绋嬪簭銆傛墦寮server.xml鏂囦欢锛屽湪Host鏍囩鍐呭缓涓涓狢ontext锛屽唴瀹瑰涓嬨

<Contextpath="/myapp" reloadable="true"docBase="D:\myapp" workDir="D:\myapp\work"/>

    鍏朵腑path鏄櫄鎷熻矾寰勶紝docBase鏄疛SP搴旂敤绋嬪簭鐨勭墿鐞嗚矾寰勶紝workDir鏄繖涓簲鐢ㄧ殑宸ヤ綔鐩綍锛屽瓨鏀捐繍琛屾槸鐢熸垚鐨勪簬杩欎釜搴旂敤鐩稿叧鐨勬枃浠躲

 

3銆佸垱寤轰竴涓狢ontext鏂囦欢

    浠ヤ笂涓ょ鏂规硶锛學eb搴旂敤琚湇鍔″櫒鍔犺浇鍚庨兘浼氬湪Tomcat鐨刢onf\catalina\localhost鐩綍涓嬬敓鎴愪竴涓猉ML鏂囦欢锛屽叾鍐呭濡備笅锛

<Contextpath="/admin"docBase="${catalina.home}/server/webapps/admin" debug="0"privileged="true"></Context>

鍙互鐪嬪嚭锛屾枃浠朵腑鎻忚堪涓涓簲鐢ㄧ▼搴忕殑Context淇℃伅锛屽叾鍐呭鍜宻erver.xml涓殑Context淇℃伅鏍煎紡鏄竴鑷寸殑锛屾枃浠跺悕渚挎槸铏氭嫙鐩綍鍚嶃傛偍鍙互鐩存帴寤虹珛杩欐牱鐨勪竴涓獂ml鏂囦欢锛屾斁鍦═omcat鐨刢onf\catalina\localhost鐩綍涓嬨備緥瀛愬涓嬶細

娉ㄦ剰锛氬垹闄や竴涓猈eb搴旂敤鍚屾椂涔熻鍒犻櫎webapps涓嬬浉搴旂殑鏂囦欢澶瑰唴server.xml涓浉搴旂殑Context锛岃繕瑕佸皢Tomcat鐨刢onf

\catalina\localhost鐩綍涓嬬浉搴旂殑xml鏂囦欢鍒犻櫎銆傚惁鍒橳omcat浠嶄細宀搁厤缃幓鍔犺浇銆傘傘 

 

tomcat閮ㄧ讲web搴旂敤涓昏鏈変互涓嬪嚑绉嶆柟寮忥細

 

1锛庢嫹璐濅綘鐨刉AR鏂囦欢鎴栬呬綘鐨剋eb搴旂敤鏂囦欢澶癸紙鍖呮嫭璇eb鐨勬墍鏈夊唴瀹癸級鍒$CATALINA_BASE/webapps鐩綍涓嬨

2锛庝负浣犵殑web鏈嶅姟寤虹珛涓涓彧鍖呮嫭context鍐呭鐨刋ML鐗囨柇鏂囦欢锛屽苟鎶婅鏂囦欢鏀惧埌$CATALINA_BASE/webapps鐩綍涓嬨傝繖涓獁eb搴旂敤鏈韩鍙互瀛樺偍鍦ㄧ‖鐩樹笂鐨勪换浣曞湴鏂广傝繖绉峜ontext鐗囨柇鎻愪緵浜嗕竴绉嶄究鍒╃殑鏂规硶鏉ラ儴缃瞱eb搴旂敤锛屼綘涓嶉渶瑕佺紪杈憇erver.xml锛岄櫎闈炰綘鎯虫敼鍙樼己鐪佺殑閮ㄧ讲鐗规э紝瀹夎涓涓柊鐨剋eb搴旂敤鏃朵笉闇瑕侀噸鍚姩Tomcat銆

3锛庡悓鏂规硶2,鍙槸灏哻ontext鐗囨柇鏀惧湪CATALINA_BASE\conf\Catalina\localhost鐩綍涓.杩欑鏂规硶姣旀柟娉2>瑕佹湁鏁,绗旇呯粡杩囧娆″疄楠屽彂鐜版柟娉2涓嶅鍚庨潰杩欑鏂规硶濂界敤.鍓嶈呭娆″嚭鐜扮郴缁熸墦涓嶅紑鐨勬儏鍐.

4锛庣洿鎺ュ湪server.xml涓</Host>鍓嶅姞涓奀ontext鐗囨柇,浣跨敤杩欑鏂规硶鏃,tomcat浼氳嚜鍔ㄥ湪CATALINA_BASE\conf\Catalina\localhost鐩綍涓嬬敓鎴愪竴涓枃浠剁墖鏂.鏂规硶鍚屾柟娉3鍏锋湁鍚屾牱鏁堟灉.杩欑鏂瑰紡闇瑕佸皢ROOT鐩綍鍒犻櫎鎵嶈.

 

鍙﹀锛屼负浜嗚tomcat鍙繍琛宑onf/server.xml涓寚瀹氱殑web搴旂敤锛屽彲浠ユ湁浠ヤ笅鍑犵鍔炴硶锛

瀹炵幇涓:

    寰俊濡備綍閫鍑烘椂鍒昏棰慱鐢靛奖澶╁爞 1)灏嗚閮ㄧ讲鐨刉EB搴旂敤鏀惧湪webapps浠ュ鐨勮矾寰, 骞跺湪server.xml鐩稿簲鐨刢ontext涓殑docBase鎸囧畾.

     2)鍒犻櫎webapps涓殑鎵鏈夋枃浠跺す, 浠ュ強conf/catalina/localhost涓嬫墍鏈墄ml鏂囦欢.

     娉: webapps鏄痵erver.xml涓殑Host鍏冪礌鐨刟ppBase灞炴х殑鍊.

瀹炵幇浜:

     1) 淇敼server.xml涓璈ost鍏冪礌鐨勫睘鎬, 娣诲姞鎴栦慨鏀:deployXML="false" deployOnStartup="false"autoDeploy="false"

     2) 鍚箟:

     鍏畨璀﹀姟鍙戝睍_鐢靛奖澶╁爞deployXML="false": 涓嶉儴缃瞔onf/catalina/localhost涓嬬殑xml鐩稿簲鐨刉EB搴旂敤    deployOnStartup="false" : tomcat鍚姩鏃, 涓嶉儴缃瞱ebapps涓嬬殑鎵鏈墂eb搴旂敤    autoDeploy="false": 閬垮厤tomcat鍦ㄦ壂鎻忔敼鍔ㄦ椂, 鍐嶆鎶妛ebapps涓嬬殑web搴旂敤缁欓儴缃茶繘鏉.

鐢靛奖澶╁爞鏈杩戞洿鏂

鐢靛奖澶╁爞鐑棬璧勮

Powered by 搜灵