我正在为Android开发一个应用程序。主屏幕有6个按钮。每个按钮指向另一个屏幕。我无法使用代码使按钮在单击时执行任何操作。这就是我所拥有的: 在主页面上,我的按钮id是玻璃,单击时打开的页面是glass.xml
android:onClick="Intent i = new Intent(FirstActivity.this, SecondActivity.class);"
和我的scr文件夹我有java活动FirstActivity.java
package install.fineline;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class FirstActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fine_line);
Button btnload = (Button) findViewById(R.id.glass);
btnload.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(this, SecondActivity.class);
startActivity(i);
}
}
和SecondActivity.java
package install.fineline;
import android.app.Activity;
import android.os.Bundle;
public class SecondActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.glass);
}
}
我做错了什么?