JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » 違規輔導區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
話題被移動
該話題已被移動 - koji , 2011-05-22 15:23
如果您尚不清楚該話題被移動的原因,請參考論壇規則以及本版公告或者聯系本版版主。
本主題所含的標籤
無標籤
作者 Android Thread問題
小頭龍





發文: 5
積分: 0
於 2011-05-22 13:32 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
想請問大家一個問題:
在寫一個Java應用在Android的程式
不過,在Debug時成功,runtime時失敗,
不知道是甚麼原因.
請大家幫忙看一下,謝啦!
Code:
package edu.tku.android;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.widget.*;
public class ApiDemos extends Activity implements Runnable{
EditText t1=(EditText)findViewById(R.id.editText1);
Thread t2 = new Thread();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
t2.start();
} catch (Exception e) {
}
}
public void run() {
int times = 10;t2.start();
try {
while (times > -1) {
t1.setText(times);
times--;
t2.sleep(1000);
if (times == 0) {
  openOptionsDialog();
}
}
} catch (Exception e) {
}
}
  private void openOptionsDialog(){
  AlertDialog.Builder b2=new AlertDialog.Builder(ApiDemos.this);
  b2.setMessage("Times up!!!");
  b2.show();
}
}
R.java檔
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package edu.tku.android;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int editText1=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
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"
>
<EditText
android:layout_height="wrap_content"
android:id="@+id/editText1"
android:layout_width="match_parent"
></EditText>
</LinearLayout>

(縮略圖,點擊圖片鏈接看原圖)


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
95 Android Thread問題 小頭龍 2322 2011-05-22 13:32
» JWorld@TW »  違規輔導區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8