真正的菜鸟在这里。我正在尝试创建第二个活动来启动第二个布局。我尝试添加 setOnClockListener 的那一刻,启动应用程序进入黑屏,从未真正加载,然后崩溃。
有两种布局:activity_main.xml 和 activity_camcord.xml。我发布了 MainActivty、第二个活动 CamcordActivity 和 Manifest。
请让我知道我还能做些什么来使这些信息足够丰富
主要活动
package com.notebook.ksen;
import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Retrieve the button object
Button imageButtonCamCord = (Button)findViewById(R.id.imageButtonCamCord);
//Attach the Listener
imageButtonCamCord.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this , CamcordActivity.class);
startActivity(intent);
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
setContentView(R.layout.activity_main);
return true;
}
}
第二活动
package com.notebook.ksen;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class CamcordActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camcord);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.camcord, menu);
setContentView(R.layout.activity_camcord);
return true;
}
}
显现
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.notebook.ksen.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity android:name=".CamcordActivity" android:label="camcord"/> </activity>
</application>