我新的ar android和我开发一个非常简单的应用程序只是为了练习。但我不知道为什么我一直得到这些错误。这是一个非常简单的应用程序,所以我不知道为什么它没有运行...
package com.tumta.salario;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
EditText SalarioEdit;
Button Calcular;
TextView SalarioTotal;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SalarioEdit = (EditText) findViewById(R.id.SalarioEditText);
Calcular = (Button) findViewById(R.id.btnCalcular);
SalarioTotal = (TextView) findViewById(R.id.SalarioTotalTextView);
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onCalcular(View view){
String SalarioText = String.valueOf(SalarioEdit.getText());
double salarioTot = Double.parseDouble(SalarioText) * 12;
SalarioTotal.setText(String.valueOf(salarioTot));
}
我的LOGCAT:
01-06 14:39:09.730: E/AndroidRuntime(5538): FATAL EXCEPTION: main
01-06 14:39:09.730: E/AndroidRuntime(5538): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.tumta.salario/com.tumta.salario.MainActivity}: java.lang.ClassNotFoundException: com.tumta.salario.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.tumta.salario-2.apk]
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.os.Looper.loop(Looper.java:130)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.app.ActivityThread.main(ActivityThread.java:3691)
01-06 14:39:09.730: E/AndroidRuntime(5538): at java.lang.reflect.Method.invokeNative(Native Method)
01-06 14:39:09.730: E/AndroidRuntime(5538): at java.lang.reflect.Method.invoke(Method.java:507)
01-06 14:39:09.730: E/AndroidRuntime(5538): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
01-06 14:39:09.730: E/AndroidRuntime(5538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
01-06 14:39:09.730: E/AndroidRuntime(5538): at dalvik.system.NativeStart.main(Native Method)
01-06 14:39:09.730: E/AndroidRuntime(5538): Caused by: java.lang.ClassNotFoundException: com.tumta.salario.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.tumta.salario-2.apk]
01-06 14:39:09.730: E/AndroidRuntime(5538): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
01-06 14:39:09.730: E/AndroidRuntime(5538): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
01-06 14:39:09.730: E/AndroidRuntime(5538): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-06 14:39:09.730: E/AndroidRuntime(5538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
01-06 14:39:09.730: E/AndroidRuntime(5538): ... 11 more
请帮帮我! 提前谢谢..
答案 0 :(得分:1)
哦,真的! public class MyActivity extends Activity!!!!!!
永远不会延伸任何其他东西!!!!并在manifest中声明你的活动!(如果你刚刚创建了它,如果不是,那么ide将默认自动声明它)
答案 1 :(得分:0)
您是否在清单中声明了活动?