Java:Button mybutton = (Button) findViewById(R.id.buttonPage1);
mybutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(MainActivity.this, SecondActivity.class);
startActivity(intent);
}
});样式:<TextView
android:id="@+id/textViewPage1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是首页" />
<Button
android:id="@+id/buttonPage1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textViewPage1"
android:layout_below="@+id/textViewPage1"
android:text="前往第二页" />其他文件:
SecondActivity.java
activity_second.xml出现的情况:
每次单击MainActivity的Button(前往第二页)按钮,程序总是错误退出。
出错信息如下:
请问这是什么原因呢?新学Android开发,谢谢大家。
mybutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(MainActivity.this, SecondActivity.class);
startActivity(intent);
}
});样式:<TextView
android:id="@+id/textViewPage1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是首页" />
<Button
android:id="@+id/buttonPage1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textViewPage1"
android:layout_below="@+id/textViewPage1"
android:text="前往第二页" />其他文件:
SecondActivity.java
activity_second.xml出现的情况:
每次单击MainActivity的Button(前往第二页)按钮,程序总是错误退出。
出错信息如下:
请问这是什么原因呢?新学Android开发,谢谢大家。
解决方案 »
- 求解!!100分!ubuntu下android源码mm编译带三方jar包的项目,javamail报错!errorIOException while sendin
- android 蓝牙串口接收不全~~~郁闷
- 地图应用开发,连wifi的时候不能显示地图,gprs可以显示,怎么回事?
- 生成库so
- 新手求教ListView的问题
- android--ImageView(context)的疑问?
- ListView,使用SimpleAdapter绑定数据,如何根据每一行的数据,改变listView的背影颜色?
- 项目中assets文件夹中有个data.xml文件!
- 关于写sql的问题
- http和socket的使用场景
- 请教关于动态生成RadioButton的问题
- android 多条通知
<activity android:name=".SecondActivity" />
Java还是要熟悉一下,花不了多少时间,先不用太关注细节。
有问题直接在这问吧,这里大神好多。