Eclipse Android应用程序崩溃 - 可能是我的import语句

时间:2012-11-01 12:47:01

标签: android eclipse crash

我正在通过一个Android应用程序开发手册并且在几个教程中遇到一些问题,因为它们都崩溃了“这种启动被配置为在挂起时打开Debug透视图”。

我在查询LogCat或Debug透视图时并不是很聪明,但我认为应用程序失败了,因为启动时间超时了。我怀疑这是关于我的import语句(可能是import android.app.ListFragment语句),但如果是这样,我不确定该怎么办。

顺便说一下,我已经尝试了我自己编写的代码和发布商网站上的源代码,但它们都崩溃了。

这是Fragment1活动的代码:

import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class Fragment1 extends ListFragment {
    String[] presidents = {
            "Dwight D. Eisenhower",
            "John F. Kennedy",
            "Lyndon B. Johnson",
            "Richard Nixon",
            "Gerald Ford",
            "Jimmy Carter",
            "Ronald Reagan",
            "George H. W. Bush",
            "Bill Clinton",
            "George W. Bush",
            "Barack Obama"
    };

    @Override
    public View onCreateView(LayoutInflater inflater, 
            ViewGroup container, Bundle savedInstanceState) {        
        return inflater.inflate(R.layout.fragment1, container, false);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1, presidents));
    }

    public void onListItemClick(ListView parent, View v, 
            int position, long id) 
    {          
        Toast.makeText(getActivity(), 
                "You have selected " + presidents[position], 
                Toast.LENGTH_SHORT).show();
    }  

}

我的布局文件的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <fragment
        android:id="@+id/fragment1"
        android:name="net.rogw.ListFragment.Fragment1"
        android:layout_width="0dp"
        android:layout_height="200dp"
        android:layout_weight="0.5" />

    <fragment
        android:id="@+id/fragment2"
        android:name="net.rogw.ListFragment.Fragment1"
        android:layout_width="0dp"
        android:layout_height="300dp"
        android:layout_weight="0.5" />

</LinearLayout>

很抱歉LogCat现在添加了延迟...

11-01 13:28:19.278: D/AndroidRuntime(5387): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-01 13:28:19.278: D/AndroidRuntime(5387): CheckJNI is ON
11-01 13:28:20.248: D/AndroidRuntime(5387): Calling main entry com.android.commands.pm.Pm
11-01 13:28:20.288: D/AndroidRuntime(5387): Shutting down VM
11-01 13:28:20.308: D/dalvikvm(5387): GC_CONCURRENT freed 101K, 78% free 462K/2048K, paused 1ms+3ms
11-01 13:28:20.308: D/dalvikvm(5387): Debugger has detached; object registry had 1 entries
11-01 13:28:20.331: I/AndroidRuntime(5387): NOTE: attach of thread 'Binder Thread #3' failed
11-01 13:28:20.967: D/AndroidRuntime(5400): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-01 13:28:20.967: D/AndroidRuntime(5400): CheckJNI is ON
11-01 13:28:21.947: D/AndroidRuntime(5400): Calling main entry com.android.commands.am.Am
11-01 13:28:21.997: I/ActivityManager(117): Force stopping package net.rogw.listfragment uid=10053
11-01 13:28:21.997: W/ActivityManager(117): Force removing ActivityRecord{41367368 net.rogw.listfragment/.ListFragment}: app died, no saved state
11-01 13:28:22.007: W/NetworkManagementSocketTagger(117): setKernelCountSet(10053, 0) failed with errno -2
11-01 13:28:22.007: I/Process(117): Sending signal. PID: 5230 SIG: 9
11-01 13:28:22.027: I/ActivityManager(117): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=net.rogw.listfragment/.ListFragment} from pid 5400
11-01 13:28:22.138: W/WindowManager(117): Failure taking screenshot for (180x300) to layer 21025
11-01 13:28:22.167: D/AndroidRuntime(5400): Shutting down VM
11-01 13:28:22.189: D/dalvikvm(5400): GC_CONCURRENT freed 101K, 77% free 485K/2048K, paused 1ms+1ms
11-01 13:28:22.189: D/dalvikvm(5400): Debugger has detached; object registry had 1 entries
11-01 13:28:22.208: I/AndroidRuntime(5400): NOTE: attach of thread 'Binder Thread #3' failed
11-01 13:28:22.267: I/WindowManager(117): createSurface Window{41b1c308 Starting net.rogw.listfragment paused=false}: DRAW NOW PENDING
11-01 13:28:22.717: W/ActivityManager(117): Activity pause timeout for ActivityRecord{41657ae8 net.rogw.listfrag/.ListFragActivity}
11-01 13:28:22.737: D/dalvikvm(5411): Not late-enabling CheckJNI (already on)
11-01 13:28:22.747: I/ActivityManager(117): Start proc net.rogw.listfragment for activity net.rogw.listfragment/.ListFragment: pid=5411 uid=10053 gids={}
11-01 13:28:22.907: W/NetworkManagementSocketTagger(117): setKernelCountSet(10053, 1) failed with errno -2
11-01 13:28:23.058: W/ActivityThread(5411): Application net.rogw.listfragment is waiting for the debugger on port 8100...
11-01 13:28:23.147: I/System.out(5411): Sending WAIT chunk
11-01 13:28:23.157: I/dalvikvm(5411): Debugger is active
11-01 13:28:23.157: I/System.out(5411): Debugger has connected
11-01 13:28:23.177: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:23.377: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:23.577: I/WindowManager(117): createSurface Window{41d169c0 Waiting For Debugger paused=false}: DRAW NOW PENDING
11-01 13:28:23.577: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:23.777: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:23.994: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:24.204: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:24.467: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:24.726: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:24.935: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:25.133: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:25.350: I/System.out(5411): waiting for debugger to settle...
11-01 13:28:25.553: I/System.out(5411): debugger has settled (1340)
11-01 13:28:32.204: W/ActivityManager(117): Launch timeout has expired, giving up wake lock!
11-01 13:28:32.978: W/ActivityManager(117): Activity idle timeout for ActivityRecord{41aaf4e0 net.rogw.listfragment/.ListFragment}
11-01 13:29:34.138: W/ThrottleService(117): unable to find stats for iface rmnet0
11-01 13:30:25.768: D/dalvikvm(390): GC_CONCURRENT freed 919K, 8% free 12830K/13895K, paused 6ms+7ms

0 个答案:

没有答案