该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
刚开始学,照着教程一个个试过去,到这里就卡住了,搞了一整天愣是没弄明白,代码反复对照了好几次实在没看出什么问题,求大神解释一下
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.Menu;
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
@Override
public boolean onKeyDown(int KeyCode,KeyEvent event){
if(KeyCode == KeyEvent.KEYCODE_DPAD_CENTER){
Intent NewStartIntent=new Intent("NewActivity");
startActivity(NewStartIntent);
}
return super.onKeyDown(KeyCode, event);
}
}
———————manifest部分———————
package="com.example.abc"
android:versionCode="1"
android:versionName="1.0" >
android:minSdkVersion="8"
android:targetSdkVersion="18" />
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name=".MyActivity"
android:label="@string/app_name" >
android:name=".NewActivity"
android:label="@string/app_name" >