代码没显示错误,就是运行的时候弹出一个“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>
!!
代码如下:
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>
08-18 04:38:24.049: DEBUG/AndroidRuntime(1227): CheckJNI is ON
08-18 04:38:24.291: DEBUG/AndroidRuntime(1227): --- registering native functions ---
08-18 04:38:26.289: DEBUG/AndroidRuntime(1227): Shutting down VM
08-18 04:38:26.299: DEBUG/dalvikvm(1227): Debugger has detached; object registry had 1 entries
08-18 04:38:26.309: INFO/AndroidRuntime(1227): NOTE: attach of thread 'Binder Thread #3' failed
08-18 04:38:27.000: DEBUG/AndroidRuntime(1237): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
08-18 04:38:27.000: DEBUG/AndroidRuntime(1237): CheckJNI is ON
08-18 04:38:27.239: DEBUG/AndroidRuntime(1237): --- registering native functions ---
08-18 04:38:28.429: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=irdc.EX04_02/.EX04_02 }
08-18 04:38:28.996: DEBUG/AndroidRuntime(1237): Shutting down VM
08-18 04:38:29.049: DEBUG/dalvikvm(1237): Debugger has detached; object registry had 1 entries
08-18 04:38:38.553: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
08-18 04:38:38.693: WARN/ActivityManager(59): Activity idle timeout for HistoryRecord{45065bc0 irdc.EX04_02/.EX04_02}
08-18 04:38:44.773: DEBUG/dalvikvm(876): GC_EXPLICIT freed 443 objects / 23576 bytes in 985ms
08-18 04:41:37.489: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol
08-18 04:42:05.592: INFO/Process(1186): Sending signal. PID: 1186 SIG: 9
08-18 04:42:05.620: INFO/ActivityManager(59): Process irdc.EX04_02 (pid 1186) has died.
08-18 04:42:05.720: INFO/UsageStats(59): Unexpected resume of cn.gshhan while already resumed in irdc.EX04_02
08-18 04:42:05.730: WARN/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4504e698
08-18 04:46:37.490: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol
08-18 04:51:37.524: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol