2012-07-18 190 views
0

我是android開發中的新成員。我正在使用Eclipse Helios和AVD 15.我正在嘗試使用一個小程序Sliding Drawer。每當我想運行它,編譯器顯示沒有錯誤,但在模擬器顯示「不幸的是停止了,我卸載它,然後運行它幾次,乾淨的項目,消除每一個警告仍然來了當我運行它在調試模式,控制檯說明: -不幸的是,應用程序已停止在Android模擬器中

[2012-07-18 12:03:34 - sliding drawer] ------------------------------ 
[2012-07-18 12:03:34 - sliding drawer] Android Launch! 
[2012-07-18 12:03:34 - sliding drawer] adb is running normally. 
[2012-07-18 12:03:34 - sliding drawer] Performing sliding.drawer.SlidingdrawerActivity 
activity launch 
[2012-07-18 12:03:34 - sliding drawer] Automatic Target Mode: launching new emulator compatible AVD 'And_em_1.5' 
[2012-07-18 12:03:34 - sliding drawer] Launching a new emulator with Virtual Device ![android debug image][1]'And_em_1.5' 
[2012-07-18 12:03:54 - sliding drawer] New emulator found: emulator-5554 
[2012-07-18 12:03:54 - sliding drawer] Waiting for HOME ('android.process.acore') to be launched... 
[2012-07-18 12:05:33 - sliding drawer] HOME is up on device 'emulator-5554' 
[2012-07-18 12:05:33 - sliding drawer] Uploading sliding drawer.apk onto device 'emulator-5554' 
[2012-07-18 12:05:33 - sliding drawer] Installing sliding drawer.apk... 
[2012-07-18 12:06:33 - sliding drawer] Success! 
[2012-07-18 12:06:33 - sliding drawer] Starting activity sliding.drawer.SlidingdrawerActivity on device emulator-5554 
[2012-07-18 12:06:36 - sliding drawer] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=sliding.drawer/.SlidingdrawerActivity } 
[2012-07-18 12:06:38 - sliding drawer] Attempting to connect debugger to 'sliding.drawer' on port 8633 

我送我的代碼:

java文件

package sliding.drawer; 

import android.app.Activity; 
import android.os.Bundle; 

public class SlidingdrawerActivity extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
} 
} 

的main.xml文件

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 
    <SlidingDrawer 
      android:id="@+id/drawer" 
      android:layout_width="320dip" 
      android:layout_height="440dip" 
      android:orientation="vertical" 
      android:handle="@+id/handle" 
      android:content="@+id/content"> 
    <ImageView 
      android:id="@+id/handle" 
      android:layout_width="48dip" 
      android:layout_height="48dip" 
      android:contentDescription="@string/s" 
      android:src="@drawable/ic_launcher" /> 
    <AnalogClock 
      android:background="#D0A0A0" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
    </SlidingDrawer> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" /> 
</RelativeLayout> 

然後窗口出現線程狀態。

線程

ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1956  
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1981 
ActivityThread.access$600(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 123  
ActivityThread$H.handleMessage(Message) line: 1147 
ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 137 
ActivityThread.main(String[]) line: 4424  
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]    
Method.invoke(Object, Object...) line: 511 
ZygoteInit$MethodAndArgsCaller.run() line: 784 
ZygoteInit.main(String[]) line: 551 
NativeStart.main(String[]) line: not available [native method] 

由於我是新android系統,我惹毛了。請幫幫我。

謝謝..

+0

我們不需要控制檯但logcat輸出。謝謝 – AMerle 2012-07-18 10:41:10

+0

嘗試給模擬時鐘ID作爲android:id =「@ + id/content」或在任何佈局採取模擬時鐘,並給予該佈局的ID如上。看到我發佈我的答案。 – AkashG 2012-07-18 10:44:50

回答

0

我認爲這個問題是您忘記id屬性您AnalogClock:在單獨視圖

<AnalogClock 
    android:id="@+id/content" 
    android:background="#D0A0A0" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 
0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" /> 

    <SlidingDrawer 
     android:id="@+id/drawer" 
     android:layout_width="320dp" 
     android:layout_height="440dp" 
     android:content="@+id/content" 
     android:handle="@+id/handle" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/handle" 
      android:layout_width="fill_parent" 
      android:layout_height="20dp" 
      /> 

     <RelativeLayout 
      android:id="@+id/content" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      > 

      <AnalogClock 
       android:background="#D0A0A0" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" /> 
     </RelativeLayout> 
    </SlidingDrawer> 

</RelativeLayout> 
0

使用AalogClock

<RelativeLayout 
     android:id="@+id/content" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/ic_launcher" > 

     <AnalogClock 
      android:background="#D0A0A0" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
    </RelativeLayout> 
相關問題