public class MainActivity extends AppCompatActivity {
String[] peoplelistStrArry;//人员数组
String peoplelistStr;//人员列表信息
String peopledetail;//人员详细信息
Bitmap peoplebmp;//人员图片
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView et= (TextView)this.findViewById(R.id.TextViewfind01);//主页面的朝文本框
Button badd= (Button)this.findViewById(R.id.ButtonAdd01);//主页面的添加按钮监听
badd.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i=new Intent(MainActivity.this,AddActivity.class);
add();
startActivity(i);
MainActivity.this.finish();
}
}
);
子页面
public class AddActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add);
EditText et1 = (EditText)this.findViewById(R.id.TextViewAdd02);
EditText et2 = (EditText)this.findViewById(R.id.TextViewAdd02);
权限文件
<activity android:name=".MainActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name=".AddActivity"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
出错
05-06 15:34:05.872 8214-8214/com.example.lenovo.tongxunex E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.lenovo.tongxunex, PID: 8214 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.lenovo.tongxunex/com.example.lenovo.tongxunex.AddActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1804)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
at android.app.Activity.startActivityForResult(Activity.java:3838)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:54)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:3799)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:708)
at android.app.Activity.startActivity(Activity.java:4109)
at android.app.Activity.startActivity(Activity.java:4077)
at com.example.lenovo.tongxunex.MainActivity$1.onClick(MainActivity.java:45)
at android.view.View.performClick(View.java:4790)
at android.view.View$PerformClick.run(View.java:19924)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5418)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
05-06 15:34:05.892 8214-8214/com.example.lenovo.tongxunex I/Process: Sending signal. PID: 8214 SIG: 9
如何解决,错误出在哪里
1 个解决方案
#1
com.example.lenovo.tongxunex/com.example.lenovo.tongxunex.AddActivity 类名称有问题
#1
com.example.lenovo.tongxunex/com.example.lenovo.tongxunex.AddActivity 类名称有问题