谁能告诉我这段代码有什么问题?
package com.lightcone.simpledialer;
public class SimpleDialer extends Activity implements OnClickListener {
private int entries = 6;
private String phoneNum[];
private String buttonLabels[];
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
phoneNum = new String[entries];
buttonLabels = new String[entries];
// Populate the data arrays
populateArrays();
// Set up buttons and attach click listeners
Button button1 = (Button)findViewById(R.id.button1);
button1.setText(buttonLabels[0]);
button1.setOnClickListener(this);
Button button2 = (Button)findViewById(R.id.button2);
button2.setText(buttonLabels[1]);
button2.setOnClickListener(this);
Button button3 = (Button)findViewById(R.id.button3);
button3.setText(buttonLabels[2]);
button3.setOnClickListener(this);
Button button4 = (Button)findViewById(R.id.button4);
button4.setText(buttonLabels[3]);
button4.setOnClickListener(this);
Button button5 = (Button)findViewById(R.id.button5);
button5.setText(buttonLabels[4]);
button5.setOnClickListener(this);
Button button6 = (Button)findViewById(R.id.button6);
button6.setText(buttonLabels[5]);
button6.setOnClickListener(this);
}
// Launch the phone dialer
public void launchDialer(String number){
String numberToDial = "tel:"+number;
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(numberToDial)));
}
/** Method to populate the data arrays */
public void populateArrays(){
/** In a practical application the arrays phoneNum and buttonLabels could be
* updated dynamically from the Web in this method. For this project we just
* hard-wire in some values to illustrate how to use such data, once obtained,
* to make phone calls.*/
phoneNum[0] = "000-000-0001";
phoneNum[1] = "000-000-0002";
phoneNum[2] = "000-000-0003";
phoneNum[3] = "000-000-0004";
phoneNum[4] = "000-000-0005";
phoneNum[5] = "000-000-0006";
buttonLabels[0] = "Jane D. Arc";
buttonLabels[1] = "John Doe";
buttonLabels[2] = "Jane Doe";
buttonLabels[3] = "Abe Linking";
buttonLabels[4] = "Mona Liza";
buttonLabels[5] = "Issac Nuton";
}
/** Process button events */
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1:
launchDialer(phoneNum[0]);
break;
case R.id.button2:
launchDialer(phoneNum[1]);
break;
case R.id.button3:
launchDialer(phoneNum[2]);
break;
case R.id.button4:
launchDialer(phoneNum[3]);
break;
case R.id.button5:
launchDialer(phoneNum[4]);
break;
case R.id.button6:
launchDialer(phoneNum[5]);
break;
}
}
public void onStart(){
super.onStart();
AdView layout = (AdView)this.findViewById(R.id.adView);
// Initiate a generic request to load it with an ad
AdRequest adRequest = new AdRequest();
adRequest.setTesting(true);
layout.loadAd(adRequest);
}
}
当我脱下这个
public void onStart(){
super.onStart();
AdView layout = (AdView)this.findViewById(R.id.adView);
// Initiate a generic request to load it with an ad
AdRequest adRequest = new AdRequest();
adRequest.setTesting(true);
layout.loadAd(adRequest);
}
该应用程序启动得很好。谢谢
这是目录
07-12 03:27:41.485: D/AndroidRuntime(10744): Shutting down VM
07-12 03:27:41.485: W/dalvikvm(10744): threadid=1: thread exiting with uncaught exception (group=0x4001d560)
07-12 03:27:41.525: E/AndroidRuntime(10744): FATAL EXCEPTION: main
07-12 03:27:41.525: E/AndroidRuntime(10744): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lightcone.simpledialer/com.lightcone.simpledialer.adMain}: java.lang.ClassNotFoundException: com.lightcone.simpledialer.adMain in loader dalvik.system.PathClassLoader[/data/app/com.lightcone.simpledialer-2.apk]
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1581)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.os.Looper.loop(Looper.java:123)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.app.ActivityThread.main(ActivityThread.java:3701)
07-12 03:27:41.525: E/AndroidRuntime(10744): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 03:27:41.525: E/AndroidRuntime(10744): at java.lang.reflect.Method.invoke(Method.java:507)
07-12 03:27:41.525: E/AndroidRuntime(10744): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
07-12 03:27:41.525: E/AndroidRuntime(10744): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
07-12 03:27:41.525: E/AndroidRuntime(10744): at dalvik.system.NativeStart.main(Native Method)
07-12 03:27:41.525: E/AndroidRuntime(10744): Caused by: java.lang.ClassNotFoundException: com.lightcone.simpledialer.adMain in loader dalvik.system.PathClassLoader[/data/app/com.lightcone.simpledialer-2.apk]
07-12 03:27:41.525: E/AndroidRuntime(10744): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-12 03:27:41.525: E/AndroidRuntime(10744): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-12 03:27:41.525: E/AndroidRuntime(10744): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-12 03:27:41.525: E/AndroidRuntime(10744): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
07-12 03:27:41.525: E/AndroidRuntime(10744): ... 11 more