不幸的是,androiddemo(项目名称)已经停止 [英] Unfortunately, androiddemo(project name) has stopped

查看:213
本文介绍了不幸的是,androiddemo(项目名称)已经停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新与Android这是我的第一个演示程序。我试图从浏览一个网页到另一个。但我不能够导航到另一个页面我在5月的主要XML文件按钮,就舔它移动到另一个XML下一页。我有2个java类:1 MianAcitvity,nextpagejava。 2 XML:activity_main,下一页

我的code:清单

 <活动
      机器人:名字=com.example.androiddemo.MainActivity
      机器人:标签=@字符串/ APP_NAME>
      &所述;意图滤光器>
          <作用机器人:名字=android.intent.action.MAIN/>            <类机器人:名字=android.intent.category.LAUNCHER/>
         &所述; /意图滤光器>
     < /活性GT;
        <活动机器人:名字=nextpagejava>< /活性GT;

MainActivity.java

 包com.example.androiddemo;
  进口android.os.Bundle;
   进口android.app.Activity;
   进口android.content.Intent;
   进口android.drm.DrmStore.Action;
  进口android.view.Menu;
   进口android.view.View;
  进口android.view.View.OnClickListener;
    进口android.widget.Button;    公共类MainActivity扩展活动实现OnClickListener {      @覆盖
     保护无效的onCreate(捆绑savedInstanceState){
         super.onCreate(savedInstanceState);
          的setContentView(R.layout.activity_main);          按钮BT =(按钮)findViewById(R.id.bnt);
           bt.setOnClickListener(新View.OnClickListener(){           @覆盖
           公共无效的onClick(视图v){
                / / TODO自动生成方法存根             }
            });
            }             @覆盖
            公共布尔onCreateOptionsMenu(菜单菜单){
            //充气菜单;如果是present这增加了项目操作栏。
              。getMenuInflater()膨胀(R.menu.activity_main,菜单);
             返回true;
            }             @覆盖
            公共无效的onClick(视图v){
              // TODO自动生成方法存根
            开关(v.getId()){
              案例R.id.bnt:
                     在意向=新意图(这一点,nextpagejava.class);
                     startActivity(在);
               打破;
              }
           }
          }

acitivity_main.xml

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
           的xmlns:工具=htt​​p://schemas.android.com/tool​​s
           机器人:layout_width =match_parent
           机器人:layout_height =match_parent
            工具:上下文=MainActivity。>               <的TextView
           机器人:ID =@ + ID / clicktxt
           机器人:layout_width =WRAP_CONTENT
           机器人:layout_height =WRAP_CONTENT
           机器人:文字=点击
         />           <按钮
           机器人:ID =@ + ID / BNT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_width =WRAP_CONTENT
           机器人:文字=点击我
          />

nextpage.xml

 <的TextView
             机器人:layout_width =match_parent
              机器人:layout_height =WRAP_CONTENT
               机器人:文字=我是一个我下页......
             />            <按钮
              机器人:ID =@ + ID / BTN1
               机器人:layout_width =match_parent
                机器人:layout_height =WRAP_CONTENT
              机器人:文字=返回
             />

nextpagejava.java

 包com.example.androiddemo;          进口android.app.Activity;
          进口android.os.Bundle;
          进口android.view.View;
          进口android.view.View.OnClickListener;
            进口android.widget.Button;           公共类nextpagejava扩展活动实现OnClickListener {       @覆盖
        保护无效的onCreate(捆绑savedInstanceState){
            super.onCreate(savedInstanceState);
              的setContentView(R.layout.activity_main);            按钮BT =(按钮)findViewById(R.id.btn1);
            bt.setOnClickListener(本);
            }          @覆盖
           公共无效的onClick(视图v){
            // TODO自动生成方法存根        }
         }

我得到消息,不幸的是,androiddemo已停止此消息作为一个弹出。

有谁能够告诉我,为什么这个错误快到了,请告诉我,从那里我可以通过线调试日志找到行。


解决方案

刚刚从你的 MainActivity.java 文件中删除这样的:


  bt.setOnClickListener(新View.OnClickListener(){
       @覆盖
       公共无效的onClick(视图v){
            / / TODO自动生成方法存根
         }
        });


而不是这样写的:


  bt.setOnClickListener(本);


也做舱单更改文件,如下:


 <活动机器人:nextpagejavaNAME =>< /活性GT;


然后检查了。我认为现在应该工作。

I am new with android this is my 1st demo app. I am trying to navigate from one page to another. But i am not able to navigate to another page i have a button in may main xml file and on licking it is moving to an another xml nextpage. I have 2 java class : 1st MianAcitvity, nextpagejava. 2 xml : activity_main, nextpage

My code : manifest

      <activity
      android:name="com.example.androiddemo.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="nextpagejava" ></activity>

MainActivity.java

package com.example.androiddemo;
  import android.os.Bundle; 
   import android.app.Activity; 
   import android.content.Intent; 
   import android.drm.DrmStore.Action;
  import android.view.Menu; 
   import android.view.View; 
  import android.view.View.OnClickListener; 
    import android.widget.Button;

    public class MainActivity extends Activity implements OnClickListener {

      @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);

          Button bt = (Button)findViewById(R.id.bnt);
           bt.setOnClickListener(new View.OnClickListener() {

           @Override
           public void onClick(View v) {
                / / TODO Auto-generated method stub

             }
            }); 
            }

             @Override
            public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
              getMenuInflater().inflate(R.menu.activity_main, menu);
             return true;
            }

             @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
            switch(v.getId()){
              case R.id.bnt:
                     Intent in = new Intent(this, nextpagejava.class);
                     startActivity(in);
               break;


              }
           }
          }

acitivity_main.xml

           <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
           xmlns:tools="http://schemas.android.com/tools"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
            tools:context=".MainActivity" >

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

           <Button
           android:id="@+id/bnt"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
           android:text="Click Me"
          />

nextpage.xml

           <TextView 
             android:layout_width="match_parent"
              android:layout_height="wrap_content"
               android:text="I am i a next page..."
             />

            <Button 
              android:id="@+id/btn1"
               android:layout_width="match_parent"
                android:layout_height="wrap_content"
              android:text="Back"
             />

nextpagejava.java

         package com.example.androiddemo;

          import android.app.Activity;
          import android.os.Bundle;
          import android.view.View;
          import android.view.View.OnClickListener;
            import android.widget.Button;

           public class nextpagejava extends Activity implements OnClickListener{

       @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);

            Button bt = (Button)findViewById(R.id.btn1);
            bt.setOnClickListener(this);
            }

          @Override
           public void onClick(View v) {
            // TODO Auto-generated method stub

        }
         }

i am getting message that "Unfortunately, androiddemo has stopped" this message as a popup.

can anybody tell me why this error is coming and please tell me from where i can find line by line debug logs.

解决方案

Just remove this from your MainActivity.java file:

  bt.setOnClickListener(new View.OnClickListener() {   
       @Override   
       public void onClick(View v) {
            / / TODO Auto-generated method stub
         }
        }); 

Instead of Write like this:

bt.setOnClickListener(this);

Also do the changes in Manifest file as below:

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

Then check out . I think it should work now.

这篇关于不幸的是,androiddemo(项目名称)已经停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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