我正在尝试获得一个简单的按钮来在屏幕之间导航,我真的不确定我做错了什么,因为我遵循了指南!
第一页代码:
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
Button aButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
} {
aButton = (Button) this.findViewById(R.id.scales);
aButton.setOnClickListener( {;new OnClickListener();
}
public void onClick(View v){
Intent i = new Intent(mainactivity.this, buttons2.class); startActivity(i);
} }
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.xx"
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.xx.MainActivity"
android:label="@string/app_name" >
android:label="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Buttons2" android:label="Buttons2"></activity>
</application>
</manifest>
第二页代码:
import android.app.Activity;
import android.os.Bundle;
public class Buttons2 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.other);
} }
请帮忙!
谢谢!