求助一下,android已停止运行

Redknot 2013-06-30 01:28:01
写了一个小程序,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>

...全文
219 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Redknot 2013-07-03
  • 打赏
  • 举报
回复
呜呜呜,忘了注册了
ihrthk 2013-06-30
  • 打赏
  • 举报
回复
mainfest注册activity了吗?
seevc 2013-06-30
  • 打赏
  • 举报
回复
同楼上疑问。
凉凉二点凉 2013-06-30
  • 打赏
  • 举报
回复
错误log呢 你的两个activity在androidmanifest.xml里面声明了没

80,350

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧