0

我是android开发的新手。我正在使用 Eclipse Helios 和 AVD 15。我正在尝试使用一个小程序 Sliding Drawer。每当我想运行它时,编译器没有显示错误,但在模拟器中显示“不幸的是已停止。我卸载它然后运行它几次,清理项目,消除每个警告仍然出现。当我在调试模式下运行它时,控制台显示:-

[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 新手,所以我很生气。请帮我。

谢谢..

4

3 回答 3

0

我认为问题是您忘记了 id 属性AnalogClock

<AnalogClock
    android:id="@+id/content"
    android:background="#D0A0A0"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
于 2012-07-18T10:45:04.063 回答
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>
于 2012-07-18T10:46:13.290 回答
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>
于 2012-07-18T10:50:53.827 回答