代码没错,就是运行不了,求救
代码没显示错误,就是运行的时候弹出一个“Sorry! the application EX04_02(process irdc.EX04_02)has stopped unexpectedly.Please try again”的窗口。求解答啊,不胜感激
!!
代码如下:
package irdc.EX04_02;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
/*使用OnClickListener与OnFocusChangeListener来区隔按钮的状态*/
import android.view.View.OnClickListener;
import android.widget.ImageButton;
//add
import android.content.Intent;
import android.widget.Button;
public class EX04_02 extends Activity
{
private ImageButton mImageButton1;
private ImageButton mImageButton2;
private ImageButton mImageButton3;
private ImageButton mImageButton4;
private ImageButton mImageButton5;
private ImageButton mImageButton6;
private ImageButton mImageButton7;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mImageButton1 =(ImageButton) findViewById(R.id.myImageButton1);
mImageButton2 =(ImageButton) findViewById(R.id.myImageButton2);
mImageButton3 =(ImageButton) findViewById(R.id.myImageButton3);
mImageButton4 =(ImageButton) findViewById(R.id.myImageButton4);
mImageButton5 =(ImageButton) findViewById(R.id.myImageButton5);
mImageButton6 =(ImageButton) findViewById(R.id.myImageButton6);
mImageButton7 =(ImageButton) findViewById(R.id.myImageButton7);
/*透过onClickListener来响应ImageButton的onClick事件*/
/* mImageButton1.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
// TODO Auto-generated method stub
mImageButton1.setImageResource(R.drawable.iconfull);
}
}
); */
//add
mImageButton1.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
// TODO Auto-generated method stub
// mImageButton1.setImageResource(R.drawable.iconfull);
Intent intent0 = new Intent(EX04_02.this,ActivityFrameLayout.class);
setTitle("FrameLayout鐨勪娇鐢�");
startActivity(intent0);
}
}
);
}
}
package irdc.EX04_02;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
public class ActivityFrameLayout extends Activity {
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.frame_layout);
Button confirm = (Button)this.findViewById(R.id.confirm);
confirm.setOnClickListener(comfirmListen);
}
OnClickListener comfirmListen = new OnClickListener(){
public void onClick(View v) {
finish();
}
};
}
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<GridView android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:columnWidth="90dp"
android:stretchMode="columnWidth"
android:gravity="center">
</GridView>
<ImageView android:id="@+id/ImageView_Big"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="95px"
android:layout_y="250px">
</ImageView>
<!--
預設圖片按鈕的default圖案透過drawable資源中取得
-->
<ImageButton
android:src="@drawable/img1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/myImageButton1"
android:layout_x="4dp"
android:layout_y="6dp">
</ImageButton>
<ImageButton
android:id="@+id/myImageButton2"
android:src="@drawable/img2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_x="114dp"
android:layout_y="6dp">
</ImageButton>
<ImageButton android:src="@drawable/img3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/myImageButton3"
android:layout_x="222dp"
android:layout_y="6dp">
</ImageButton>
<ImageButton
android:src="@drawable/img4"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/myImageButton4"
android:layout_x="4dp"
android:layout_y="114dp">
</ImageButton>
<ImageButton
android:src="@drawable/img5"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/myImageButton5"
android:layout_x="114dp"
android:layout_y="114dp">
</ImageButton>
<ImageButton
android:src="@drawable/img6"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/myImageButton6"
android:layout_x="222dp"
android:layout_y="114dp">
</ImageButton>
<ImageButton
android:src="@drawable/img7"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/myImageButton7"
android:layout_x="4dp"
android:layout_y="228dp">
</ImageButton>
</AbsoluteLayout>