当前位置:编程学习 > wap >>

新人求助,请各位前辈帮我看看错误在哪里



这是logcat
通过intent跳转activity  ecplise没提示错误但是程序不能运行 多谢各位前辈啦 android --------------------编程问答-------------------- 有没有在AndroidManifest.xml中把所有的Activity都注册了?把代码贴上来看一下吧。。。 --------------------编程问答--------------------
引用 1 楼 MrIELTS 的回复:
有没有在AndroidManifest.xml中把所有的Activity都注册了?把代码贴上来看一下吧。。。

package com.example.shishenxuanze;

import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.widget.Button;

public class Shishenxuanze extends Activity {
private Button button1 = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shishenxuanze);
button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener((android.view.View.OnClickListener) new MyButtonListener());

}
   class MyButtonListener implements OnClickListener{

@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Shishenxuanze.this, Zishibu.class);
Shishenxuanze.this.startActivity(intent);
}
   
   
   }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.shishenxuanze, menu);
return true;
}

}
这是第一个activity
package com.example.shishenxuanze;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class Zishibu extends Activity {
private ImageView imageview1 = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.zishibu);
imageview1 = (ImageView)findViewById(R.id.imageView1);
}

}
第二个activity
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.shishenxuanze"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.shishenxuanze.Shishenxuanze"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.example.shishenxuanze.Zishibu"
                  android:label="@string/app_name"/>
    </application>

</manifest>
AndroidMainfest.xml --------------------编程问答-------------------- 你把 Shishenxuanze这个类名换成别的名字试试 --------------------编程问答-------------------- 我记得貌似button用的onclick后面应该是  onclick(View v){......}吧 --------------------编程问答-------------------- class MyButtonListener implements OnClickListener{

@Override
public void onClick(DialogInterface arg0, int arg1)
这个方法引用错了,应该是public void onClick(View v)
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,