unfortunately,launcher has stopped

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lovexiaoxiao/article/details/9263237

启动模拟器的时候就会报错:

unfortunately,launcher has stopped

这时候要注意你创建项目版本


阅读更多

unfortunately ,getposition has stopped

04-23

rn04-23 11:14:09.654: E/AndroidRuntime(1252): Process: com.example.getposition, PID: 1252rn04-23 11:14:09.654: E/AndroidRuntime(1252): java.lang.RuntimeException: Unable to start activity ComponentInfocom.example.getposition/com.example.getposition.GetPositionActivity: java.lang.NullPointerExceptionrn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.ActivityThread.access$800(ActivityThread.java:135)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.os.Handler.dispatchMessage(Handler.java:102)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.os.Looper.loop(Looper.java:136)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.ActivityThread.main(ActivityThread.java:5017)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at java.lang.reflect.Method.invokeNative(Native Method)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at java.lang.reflect.Method.invoke(Method.java:515)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at dalvik.system.NativeStart.main(Native Method)rn04-23 11:14:09.654: E/AndroidRuntime(1252): Caused by: java.lang.NullPointerExceptionrn04-23 11:14:09.654: E/AndroidRuntime(1252): at com.example.getposition.DbService.scanSQL(DbService.java:47)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at com.example.getposition.GetPositionActivity.onCreate(GetPositionActivity.java:63)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.Activity.performCreate(Activity.java:5231)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)rn04-23 11:14:09.654: E/AndroidRuntime(1252): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)rn04-23 11:14:09.654: E/AndroidRuntime(1252): ... 11 morern04-23 11:14:13.884: I/Process(1252): Sending signal. PID: 1252 SIG: 9rnrn上面的是logcat里面的,小白看不懂,求解决

关于unfortunately has stopped的问题

10-16

logcat日志猫:rn10-15 22:53:02.319: E/AndroidRuntime(2974): FATAL EXCEPTION: mainrn10-15 22:53:02.319: E/AndroidRuntime(2974): Process: com.itheima.qq, PID: 2974rn10-15 22:53:02.319: E/AndroidRuntime(2974): java.lang.RuntimeException: Unable to instantiate activity ComponentInfocom.itheima.qq/qq.MainActivity: java.lang.ClassNotFoundException: Didn't find class "qq.MainActivity" on path: DexPathList[[zip file "/data/app/com.itheima.qq-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.itheima.qq-1, /system/lib]]rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.access$800(ActivityThread.java:135)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.os.Handler.dispatchMessage(Handler.java:102)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.os.Looper.loop(Looper.java:136)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.main(ActivityThread.java:5017)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.reflect.Method.invokeNative(Native Method)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.reflect.Method.invoke(Method.java:515)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at dalvik.system.NativeStart.main(Native Method)rn10-15 22:53:02.319: E/AndroidRuntime(2974): Caused by: java.lang.ClassNotFoundException: Didn't find class "qq.MainActivity" on path: DexPathList[[zip file "/data/app/com.itheima.qq-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.itheima.qq-1, /system/lib]]rn10-15 22:53:02.319: E/AndroidRuntime(2974): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)rn10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)rn10-15 22:53:02.319: E/AndroidRuntime(2974): ... 11 morern

unfortunately ,....has stopped问题求解决

04-20

我按照网上给的教学视频编写一个多选框的案例,程序编译是对的,但是当apk程序在虚拟机上运行的时候就出现unfortunately ,....has stopped这样的错误rn[color=#FF0000][b]错误一[/b][/color]rn具体代码如下:rn//main_activity.javarnpackage com.dylan.s01_e09_checkbox;rnrnimport android.app.Activity;rnimport android.app.Fragment;rnimport android.os.Bundle;rnimport android.view.LayoutInflater;rnimport android.view.Menu;rnimport android.view.MenuItem;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.view.ViewGroup;rnimport android.widget.CheckBox;rnrnpublic class MainActivity extends Activity rn rn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rnrn if (savedInstanceState == null) rn getFragmentManager().beginTransaction()rn .add(R.id.container, new PlaceholderFragment()).commit();rn rn rnrn @Overridern public boolean onCreateOptionsMenu(Menu menu) rnrn // Inflate the menu; this adds items to the action bar if it is present.rn getMenuInflater().inflate(R.menu.main, menu);rn return true;rn rnrn @Overridern public boolean onOptionsItemSelected(MenuItem item) rn // Handle action bar item clicks here. The action bar willrn // automatically handle clicks on the Home/Up button, so longrn // as you specify a parent activity in AndroidManifest.xml.rn int id = item.getItemId();rn if (id == R.id.action_settings) rn return true;rn rn return super.onOptionsItemSelected(item);rn rnrn /**rn * A placeholder fragment containing a simple view.rn */rn public static class PlaceholderFragment extends Fragment rnrn public PlaceholderFragment() rn rnrn @Overridern public View onCreateView(LayoutInflater inflater, ViewGroup container,rn Bundle savedInstanceState) rn View rootView = inflater.inflate(R.layout.fragment_main, container,rn false);rn[color=#FF0000] CheckBox eatBox = (CheckBox)rootView.findViewById(R.id.eatId);rn CheckBox sleepBox = (CheckBox)rootView.findViewById(R.id.sleepId);rn CheckBox dotaBox = (CheckBox)rootView.findViewById(R.id.dotaId);rn rn OnBoxClickListener listener = new OnBoxClickListener();rn eatBox.setOnClickListener(listener);rn sleepBox.setOnClickListener(listener);rn dotaBox.setOnClickListener(listener);[/color]rn rn return rootView;rn rn rn[color=#FF0000] public static class OnBoxClickListener implements OnClickListenerrnrn @Overridern public void onClick(View arg0) rn System.out.println("Checkbox is clicked");rn rn rn [/color]rnrnrn红色字体部分是我添加的代码。。。rnfragment_main.xml文件如下:rnrnrnrn rn rn rn rn rnrnrnrnrn出现错误的logcat代码如下:rn[color=#FF0000]04-20 06:26:29.158: E/AndroidRuntime(1107): java.lang.RuntimeException: Unable to start activity ComponentInfocom.dylan.s01_e09_checkbox/com.dylan.s01_e09_checkbox.MainActivity: android.view.InflateException: Binary XML file line #8: Error inflating class CheckBok[/color]rnrn[color=#FF0000][b]错误二[/b][/color]rn还有就是在我每次保存main_activity文件的时候总会跳出rn[color=#FF0000]'Running Android Lint' has encountered a problemrnAn internal error occurred during :"Running Android Lint"[/color]rnrn虽然这个错误提示不影响整体的运行结果,但总是看到心里还是不舒服的。。。rn请问这些问题怎么解决啊,大神求帮忙了。。。rn

Android开发新手:unfortunately,***has stopped

01-25

新手刚开始跟着Mars老师开始学安卓开发,程序运行时遇到unfortunately,***has stopped的问题:rnactivity_main.xml:rn[code=html]rn[/code]rnrnfragment_main.xml:rn[code=html]rnrn rnrn rnrnrn[/code]rnMainActivity.java:rn[code=java]package com.liangjie.s01_e05_view;rnrnimport android.app.Activity;rnimport android.app.Fragment;rnimport android.graphics.Color;rnimport android.os.Bundle;rnimport android.view.LayoutInflater;rnimport android.view.Menu;rnimport android.view.MenuItem;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.view.ViewGroup;rnimport android.widget.Button;rnimport android.widget.TextView;rnrnpublic class MainActivity extends Activity rnrn private TextView textView;rn private Button button;rn int count = 0;rn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rn rn textView = (TextView)findViewById(R.id.textView);rn button = (Button)findViewById(R.id.button);rn rn ButtonListener buttonListener = new ButtonListener();rn button.setOnClickListener(buttonListener);rn //textView.setText("Hello Jie"); rn //textView.setBackgroundColor(Color.BLUE);rn if (savedInstanceState == null) rn getFragmentManager().beginTransaction()rn .add(R.id.container, new PlaceholderFragment())rn .commit();rn rn rnrnrn @Overridern public boolean onCreateOptionsMenu(Menu menu) rn rn // Inflate the menu; this adds items to the action bar if it is present.rn getMenuInflater().inflate(R.menu.main, menu);rn return true;rn rn rn class ButtonListener implements OnClickListener rnrn @Overridern public void onClick(View arg0) rn count ++;rn textView.setTag(count + "");rn rn rn rnrn @Overridern public boolean onOptionsItemSelected(MenuItem item) rn // Handle action bar item clicks here. The action bar willrn // automatically handle clicks on the Home/Up button, so longrn // as you specify a parent activity in AndroidManifest.xml.rn int id = item.getItemId();rn if (id == R.id.action_settings) rn return true;rn rn return super.onOptionsItemSelected(item);rn rnrn /**rn * A placeholder fragment containing a simple view.rn */rn public static class PlaceholderFragment extends Fragment rnrn public PlaceholderFragment() rn rnrn @Overridern public View onCreateView(LayoutInflater inflater, ViewGroup container,rn Bundle savedInstanceState) rn View rootView = inflater.inflate(R.layout.fragment_main, container, false);rn return rootView;rn rn rnrnrn[/code]rnrnLogCat日志:rn[code=text]01-25 00:41:11.993: D/AndroidRuntime(1522): Shutting down VMrn01-25 00:41:11.993: W/dalvikvm(1522): threadid=1: thread exiting with uncaught exception (group=0xb3a3bba8)rn01-25 00:41:12.013: E/AndroidRuntime(1522): FATAL EXCEPTION: mainrn01-25 00:41:12.013: E/AndroidRuntime(1522): Process: com.liangjie.s01_e05_view, PID: 1522rn01-25 00:41:12.013: E/AndroidRuntime(1522): java.lang.RuntimeException: Unable to start activity ComponentInfocom.liangjie.s01_e05_view/com.liangjie.s01_e05_view.MainActivity: java.lang.NullPointerExceptionrn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.ActivityThread.access$800(ActivityThread.java:135)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.os.Handler.dispatchMessage(Handler.java:102)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.os.Looper.loop(Looper.java:136)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.ActivityThread.main(ActivityThread.java:5017)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at java.lang.reflect.Method.invokeNative(Native Method)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at java.lang.reflect.Method.invoke(Method.java:515)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at dalvik.system.NativeStart.main(Native Method)rn01-25 00:41:12.013: E/AndroidRuntime(1522): Caused by: java.lang.NullPointerExceptionrn01-25 00:41:12.013: E/AndroidRuntime(1522): at com.liangjie.s01_e05_view.MainActivity.onCreate(MainActivity.java:30)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.Activity.performCreate(Activity.java:5231)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)rn01-25 00:41:12.013: E/AndroidRuntime(1522): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)rn01-25 00:41:12.013: E/AndroidRuntime(1522): ... 11 morern01-25 00:41:13.983: I/Process(1522): Sending signal. PID: 1522 SIG: 9rn[/code]rnrn求高手解答一下。。。

为什么会出现unfortunately has stopped

12-03

[code=java]rnpackage com.ex06.button;rnrnimport android.app.Activity;rnimport android.os.Bundle;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.Button;rnrnpublic class ActivityButton extends Activity rnrn Button button1 = (Button) findViewById(R.id.button1);rn Button button2 = (Button) findViewById(R.id.button2);rnrn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn button1.setOnClickListener(new View.OnClickListener() rn public void onClick(View v) rn setTitle("button1 点击后不可见");rn button1.setVisibility(View.INVISIBLE);rn button2.setVisibility(View.VISIBLE);rn rn );rn button2.setOnClickListener(new View.OnClickListener() rn public void onClick(View v) rn setTitle("button2 点击后不可见");rn button2.setVisibility(View.INVISIBLE);rn button1.setVisibility(View.VISIBLE);rn rn );rn rn[/code]rn我建两个button,为什么会出现这种情况rnlogcatrn[code=text]rn12-02 20:57:40.865: E/AndroidRuntime(1658): FATAL EXCEPTION: mainrn12-02 20:57:40.865: E/AndroidRuntime(1658): Process: com.ex06.button, PID: 1658rn12-02 20:57:40.865: E/AndroidRuntime(1658): java.lang.RuntimeException: Unable to instantiate activity ComponentInfocom.ex06.button/com.ex06.button.ActivityButton: java.lang.NullPointerExceptionrn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2102)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.ActivityThread.access$700(ActivityThread.java:135)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.os.Handler.dispatchMessage(Handler.java:102)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.os.Looper.loop(Looper.java:137)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.ActivityThread.main(ActivityThread.java:4998)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at java.lang.reflect.Method.invokeNative(Native Method)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at java.lang.reflect.Method.invoke(Method.java:515)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at dalvik.system.NativeStart.main(Native Method)rn12-02 20:57:40.865: E/AndroidRuntime(1658): Caused by: java.lang.NullPointerExceptionrn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.Activity.findViewById(Activity.java:1883)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at com.ex06.button.ActivityButton.(ActivityButton.java:11)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at java.lang.Class.newInstanceImpl(Native Method)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at java.lang.Class.newInstance(Class.java:1208)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)rn12-02 20:57:40.865: E/AndroidRuntime(1658): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093)rn12-02 20:57:40.865: E/AndroidRuntime(1658): ... 11 morern12-02 20:57:45.135: I/Process(1658): Sending signal. PID: 1658 SIG: 9rn[/code]

运行时出现unfortunately *** has stopped了,求解! ...

06-30

新手,第一天实战,运行时出现:运行时出现unfortunately *** has stopped了,求解!rn这MainActivity:rnpackage com.mingrisoft;rnimport android.app.Activity;rnimport android.graphics.drawable.AnimationDrawable;rnimport android.os.Bundle;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.LinearLayout;rnpublic class MainActivity extends Activity rnprivate boolean flag=true;rn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.main);rn LinearLayout ll=(LinearLayout)findViewById(R.id.ll); //获取布局文件中添加的线性布局管理器rn rn rn final AnimationDrawable anim=(AnimationDrawable)ll.getBackground(); //获取AnimationDrawable对象rn //为线性布局管理器添加单击事件监听器rn ll.setOnClickListener(new OnClickListener() rn rn @Overridern public void onClick(View v) rn if(flag)rn anim.start(); //开始播放动画rn flag=false;rn elsern anim.stop(); //停止播放动画rn flag=true;rn rn rn );rn rnrnrn这个是logrnrn06-30 06:43:09.230: D/dalvikvm(902): GC_FOR_ALLOC freed 53K, 5% free 2785K/2912K, paused 205ms, total 208msrn06-30 06:43:09.270: I/dalvikvm-heap(902): Grow heap (frag case) to 10.698MB for 8294416-byte allocationrn06-30 06:43:09.420: D/dalvikvm(902): GC_FOR_ALLOC freed 2K, 2% free 10883K/11016K, paused 143ms, total 143msrn06-30 06:43:14.330: D/AndroidRuntime(902): Shutting down VMrn06-30 06:43:14.330: W/dalvikvm(902): threadid=1: thread exiting with uncaught exception (group=0xb2a92ba8)rn06-30 06:43:14.350: E/AndroidRuntime(902): FATAL EXCEPTION: mainrn06-30 06:43:14.350: E/AndroidRuntime(902): Process: com.mingrisoft, PID: 902rn06-30 06:43:14.350: E/AndroidRuntime(902): java.lang.RuntimeException: Unable to start activity ComponentInfocom.mingrisoft/com.mingrisoft.MainActivity: java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.AnimationDrawablern06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.ActivityThread.access$800(ActivityThread.java:135)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.os.Handler.dispatchMessage(Handler.java:102)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.os.Looper.loop(Looper.java:136)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.ActivityThread.main(ActivityThread.java:5017)rn06-30 06:43:14.350: E/AndroidRuntime(902): at java.lang.reflect.Method.invokeNative(Native Method)rn06-30 06:43:14.350: E/AndroidRuntime(902): at java.lang.reflect.Method.invoke(Method.java:515)rn06-30 06:43:14.350: E/AndroidRuntime(902): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)rn06-30 06:43:14.350: E/AndroidRuntime(902): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)rn06-30 06:43:14.350: E/AndroidRuntime(902): at dalvik.system.NativeStart.main(Native Method)rn06-30 06:43:14.350: E/AndroidRuntime(902): Caused by: java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.AnimationDrawablern06-30 06:43:14.350: E/AndroidRuntime(902): at com.mingrisoft.MainActivity.onCreate(MainActivity.java:21)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.Activity.performCreate(Activity.java:5231)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)rn06-30 06:43:14.350: E/AndroidRuntime(902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)rn06-30 06:43:14.350: E/AndroidRuntime(902): ... 11 morern06-30 06:45:07.260: I/Process(902): Sending signal. PID: 902 SIG: 9rn06-30 06:45:44.300: D/dalvikvm(1302): GC_FOR_ALLOC freed 49K, 5% free 2785K/2908K, paused 44ms, total 45msrn06-30 06:45:44.300: I/dalvikvm-heap(1302): Grow heap (frag case) to 10.698MB for 8294416-byte allocationrn06-30 06:45:44.760: D/dalvikvm(1302): GC_FOR_ALLOC freed 2K, 2% free 10883K/11012K, paused 53ms, total 54msrn06-30 06:45:45.900: D/AndroidRuntime(1302): Shutting down VMrn06-30 06:45:45.900: W/dalvikvm(1302): threadid=1: thread exiting with uncaught exception (group=0xb2a92ba8)rn06-30 06:45:45.910: E/AndroidRuntime(1302): FATAL EXCEPTION: mainrn06-30 06:45:45.910: E/AndroidRuntime(1302): Process: com.mingrisoft, PID: 1302rn06-30 06:45:45.910: E/AndroidRuntime(1302): java.lang.RuntimeException: Unable to start activity ComponentInfocom.mingrisoft/com.mingrisoft.MainActivity: java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.AnimationDrawablern06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.ActivityThread.access$800(ActivityThread.java:135)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.os.Handler.dispatchMessage(Handler.java:102)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.os.Looper.loop(Looper.java:136)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.ActivityThread.main(ActivityThread.java:5017)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at java.lang.reflect.Method.invokeNative(Native Method)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at java.lang.reflect.Method.invoke(Method.java:515)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at dalvik.system.NativeStart.main(Native Method)rn06-30 06:45:45.910: E/AndroidRuntime(1302): Caused by: java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.AnimationDrawablern06-30 06:45:45.910: E/AndroidRuntime(1302): at com.mingrisoft.MainActivity.onCreate(MainActivity.java:19)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.Activity.performCreate(Activity.java:5231)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)rn06-30 06:45:45.910: E/AndroidRuntime(1302): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)rn06-30 06:45:45.910: E/AndroidRuntime(1302): ... 11 morern06-30 06:46:30.070: I/Process(1302): Sending signal. PID: 1302 SIG: 9rn

activity跳转问题(unfortunately activity has stopped

07-16

程序功能:点下按钮跳转到另一个OtherActivity,并且显示信息。rn代码如下:rnMainActivity.javarn[code=Java]rnpackage com.example.activity;rnrnimport android.os.Bundle;rnimport android.view.*;rnimport android.annotation.SuppressLint;rnimport android.app.Activity;rnimport android.content.Intent;rnimport android.view.Menu;rnimport android.view.MenuItem;rnimport android.view.View;rnimport android.widget.Button;rnimport android.widget.TextView;rnimport android.support.v4.app.NavUtils;rnrn@SuppressLint("ParserError")rnpublic class MainActivity extends Activity rn rn public Button myButton=null;rn public TextView myTextView=null;rn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rn myButton=(Button)findViewById(R.id.myButton);rn myButton.setText("jump to activytyOther");rn myButton.setOnClickListener(new myButtonMonitor());rn rn myTextView=(TextView)findViewById(R.id.myTextView);rn rnrn @Overridern public boolean onCreateOptionsMenu(Menu menu) rn getMenuInflater().inflate(R.menu.activity_main, menu);rn return true;rn rnrn public class myButtonMonitor implements View.OnClickListenerrnrn public void onClick(View v) rn Intent intent=new Intent();rn intent.setClass(MainActivity.this, OtherActivity.class);rn intent.putExtra("msg", 123);rn MainActivity.this.startActivity(intent);rn MainActivity.this.myTextView.setText("button clicked!");//这里没有问题rn rn rn rnrnrn[/code]rnrnOtherActivity.javarn[code=Java]rnpackage com.example.activity;rnrnimport android.app.Activity;rnimport android.os.Bundle;rnimport android.widget.TextView;rnrnpublic class OtherActivity extends Activityrnrn public TextView myTextView=null;rn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn this.myTextView=(TextView)findViewById(R.id.a);//这里是我感觉不对的地方rn this.myTextView.setText("This Is Other Activty!");rn rn rn rnrnrnrn[/code]rnrnMainActivity的布局xml:rn[code=XML]rnrnrn rn rnrnrnrn[/code]rnrnOtherActivity的布局xml:rn[code=XML]rnrnrn rnrnrn[/code]rnrnrnrn rnrn rn rn rn rnrn rn rn rn rn rn rn rnrnrnrnrnrn1.button的监听类里边加入了一个测试,这个测试成功,说明按钮的动作实现没问题rn2.当OtherActivity里边不加入任何控件的时候,可以实现跳转,可见intent的实现应该没问题rn3.当OtherActivity里边加入了控件的时候,android模拟器提示Unfortunately Activity has stoppedrn4.个人感觉是R.id.Something出了问题rnrn我是新手,困扰很久了这个问题,请教各位高手,谢谢了

没有更多推荐了,返回首页