"不幸的是我的应用程序已经停止" [英] "Unfortunately My App has stopped"

查看:120
本文介绍了"不幸的是我的应用程序已经停止"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i'was创建一个Android的应用程序,但没有发现错误不幸的是我的应用程序已经停止,请帮助我

i'was create a app for android but there is a error found " Unfortunately My App has stopped " so please help me

AndroidManifest的.xml

AndroidManifest .xml

            <?xml version="1.0" encoding="utf-8"?>
            <manifest xmlns:android="http://schemas.android.com/apk/res/android"
             package="com.example.techtips"
             android:versionCode="1"
             android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.techblogon.activitylifecycleexample.MainActivity"
        android:label="@string/app_name" >

     <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity 
        android:name=".SecondActivity">
    </activity>

    </application>

 </manifest>

RES /布局

布局2的.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent">

  <TextView
     android:id="@+id/textView1"
     android:layout_marginTop="150dp"
     android:layout_gravity="center_horizontal"
     android:textSize="23dp"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="This Is Second Activity" />

 </LinearLayout>

的main.xml

main.xml

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

        <TextView

           android:id="@+id/textView1"
           android:layout_gravity="center_horizontal"
           android:textSize="23dp"
           android:layout_marginTop="150dp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="This Is Fist Activity Activity"/>

        <Button
           android:id="@+id/button1"
           android:layout_gravity="center_horizontal"
           android:layout_marginTop="20dp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="      Second Activity     " 
           android:onClick="startSecondActivity"/>


        </LinearLayout>

的src /com.example.techtip/
   MainActivity.java

src /com.example.techtip/ MainActivity.java

        package com.example.techtips;

        import android.os.Bundle;
        import android.app.Activity;
        import android.content.Intent;
        import android.util.Log;
        import android.view.View;
        import android.widget.Toast;


     public class MainActivity extends Activity {
         /** Called when the activity is first created. */

     @Override

       public void onCreate(Bundle savedInstanceState) 
     {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Toast.makeText(this, "On Create Called In First Activity",                  

    Toast.LENGTH_LONG).show();
        Log.i("FirstActivity", "Inside onCreate");        
    }   

   @Override

  protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    Toast.makeText(this, "On Start Called In First Activity",    

   Toast.LENGTH_LONG).show();
      Log.i("FirstActivity", "Inside onStart");

   }   

   @Override

    protected void onResume()

 {

       // TODO Auto-generated method stub

       super.onResume();

    Toast.makeText(this, "On Resume Called In First Activity",   

   Toast.LENGTH_LONG).show();
     Log.i("FirstActivity", "Inside onResume");
} 

@Override

protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    Toast.makeText(this, "On Pause Called In First Activity", 

Toast.LENGTH_LONG).show();
    Log.i("FirstActivity", "Inside onPause");
}

 @Override

protected void onStop() {
    // TODO Auto-generated method stub
    super.onStop();

    Toast.makeText(this, "On Stop Called In First Activity", Toast.LENGTH_LONG).show();
    Log.i("FirstActivity", "Inside onStop");
}

@Override

protected void onDestroy() 
 {
    // TODO Auto-generated method stub
    super.onDestroy();
    Toast.makeText(this, "On Destroy Called In First Activity", 

 Toast.LENGTH_LONG).show();
    Log.i("FirstActivity", "Inside onDestroy");

 }
 public void startSecondActivity(View V)
 {
    // create an new Intent and Start Second Activity
    Intent intent=new Intent(this,SecondActivity.class);
    startActivity(intent);
  }
}

SecondActivity.java

SecondActivity.java

  package com.example.techtips;

    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;
    import android.widget.Toast;


   public class SecondActivity extends Activity
{
  /** Called when the activity is first created. */


@Override

  public void onCreate(Bundle savedInstanceState) 
{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout2);
        Toast.makeText(this, "On Create Called In Second Activity", 

 Toast.LENGTH_LONG).show();
        Log.i("SecondActivity", "Inside onCreate");

}   

@Override

  protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    Toast.makeText(this, "On Start Called In Second Activity", 

   Toast.LENGTH_LONG).show();
    Log.i("SecondActivity", "Inside onStart");
}  

@Override

 protected void onResume()
{
    // TODO Auto-generated method stub
    super.onResume();

    Toast.makeText(this, "On Resume Called In Second Activity", 

    Toast.LENGTH_LONG).show();

           Log.i("SecondActivity", "Inside onResume");
}  

@Override

  protected void onPause() {
     // TODO Auto-generated method stub
    super.onPause();
    Toast.makeText(this, "On Pause Called In Second Activity", 

Toast.LENGTH_LONG).show();
     Log.i("SecondActivity", "Inside onPause");
 }


 @Override

protected void onStop() {
     // TODO Auto-generated method stub
    super.onStop();

    Toast.makeText(this, "On Stop Called In Second Activity",  

  Toast.LENGTH_LONG).show();

            Log.i("SecondActivity", "Inside onStop");
}

 @Override

 protected void onDestroy() 
{
    // TODO Auto-generated method stub
    super.onDestroy();
    Toast.makeText(this, "On Destroy Called In Second Activity", 

  Toast.LENGTH_LONG).show();
    Log.i("SecondActivity", "Inside onDestroy");    
   }
 }

请帮助他解解

Please Help He for Solution

和还请大家帮我出创建简单的应用程序是这样?请帮我出

And also please help me out for create Simple app like this ?? Please Help mE Out

图片:i.stack.imgur.com/20iUi.jpg

Image : i.stack.imgur.com/20iUi.jpg

推荐答案

在您的清单文件包名不加起来IMO。先试着改正;

The package names in your manifest file dont add up IMO. First try to correct them;

package="com.example.techtips"

   <activity
        android:name="com.techblogon.activitylifecycleexample.MainActivity"
        android:label="@string/app_name" >

试着改变第二个:

Try changing the second to:

 <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >

这篇关于&QUOT;不幸的是我的应用程序已经停止&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆