当前位置:编程学习 > wap >>

求助一下,android已停止运行

写了一个小程序,eclipse没有报错,警告都没有,放到手机上就总是显示已停止运行。这是代码:
MainActivity.java:
package redknot.com.example.redphone;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;


public class MainActivity extends Activity {
    private Button buttonphone;
    private Button buttontext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        buttonphone = (Button) findViewById(R.id.buttonphone);
        buttontext = (Button) findViewById(R.id.buttontext);
        
        buttonphone.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intentphone = new Intent(MainActivity.this,Phone.class);
startActivity(intentphone);
}
        
        });
        
        buttontext.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intenttext = new Intent(MainActivity.this,Text.class);
startActivity(intenttext);
}
        
        });
        
     
    }


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


activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    
    <Button 
        android:id="@+id/buttonphone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/gotophone"
        />
    <Button 
        android:id="@+id/buttontext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/gototext"
        />
</LinearLayout>

Android 手机 Eclipse --------------------编程问答-------------------- 错误log呢
你的两个activity在androidmanifest.xml里面声明了没 --------------------编程问答-------------------- 同楼上疑问。 --------------------编程问答-------------------- mainfest注册activity了吗? --------------------编程问答-------------------- 呜呜呜,忘了注册了
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,