做这个
imageButton =(ImageButton)findViewById(R.id.imageButton4);
imageButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(YourCurrentCLass.this,Settings.class);
startActivity(intent);
}
});
并检查您的清单
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sampledatabase"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
如果你只看到<category android:name="android.intent.category.LAUNCHER" />
和不<category android:name="android.intent.category.DEFAULT" />
像这样创建一个新活动
<activity
android:name=".Settings"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="name.of.your.package.Settings" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
记得把它放在你的<application
标签里,和你的 .MainActivity 一样