我无法让我的应用程序运行!它没有编译错误,安装完美。但是当我单击自定义按钮时,应用程序会停止。我复制了整个 java 和 xml 文件并使用一个 TextView 进行了一个简单的活动,并且它有效。它进入活动并显示 TextView。下面是 java、xml 和 logcat 代码:
package l.pocketformulas;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class Formulas extends Activity {
Button bAlgebra, bTrigonometry, bCalculus, bGeometry;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// FULL SCREEN & HIDE APP TITLE
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.formulas);
initVars();
bAlgebra.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent algebraInt = new Intent("android.intent.action.ALGEBRA");
startActivity(algebraInt);
}
});
bTrigonometry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent trigonometryInt = new Intent(
"android.intent.action.TRIGONOMETRY");
startActivity(trigonometryInt);
}
});
bGeometry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent geometryInt = new Intent(
"android.intent.action.GEOMETRY");
startActivity(geometryInt);
}
});
bCalculus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent calculusInt = new Intent(
"android.intent.action.CALCULUS");
startActivity(calculusInt);
}
});
}
private void initVars() {
// TODO Auto-generated method stub
bAlgebra = (Button) findViewById(R.id.bAlgebra);
bTrigonometry = (Button) findViewById(R.id.bTrigonometry);
bCalculus = (Button) findViewById(R.id.bCalculus);
bGeometry = (Button) findViewById(R.id.bGeometry);
}
}
这是 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bgr"
android:orientation="vertical" >
<include layout="@layout/selectimg"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="@+id/bAlgebra"
android:layout_height="148dp"
android:layout_weight="50"
android:background="@drawable/algebra" />
<Button
android:id="@+id/bGeometry"
android:layout_height="148dp"
android:layout_weight="50"
android:background="@drawable/geometry" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="@string/algebra"
android:textColor="@android:color/holo_red_dark"
android:textSize="25sp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="@string/geometry"
android:textColor="@android:color/holo_red_dark"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="@+id/bTrigonometry"
android:layout_height="148dp"
android:layout_weight="50"
android:background="@drawable/trigonometry" />
<Button
android:id="@+id/bCalculus"
android:layout_height="148dp"
android:layout_weight="50"
android:background="@drawable/calculus" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="@string/trigonometry"
android:textColor="@android:color/holo_red_dark"
android:textSize="25sp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="@string/calculus"
android:textColor="@android:color/holo_red_dark"
android:textSize="25sp" />
</LinearLayout>
这是Logcat:
06-05 00:17:25.090: E/Trace(24203): error opening trace file: No such file or directory (2)
06-05 00:17:25.450: I/Adreno200-EGL(24203): <qeglDrvAPI_eglInitialize:299>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.02.21.081_msm7627a_JB_REL_2.0.3_CL2820657_release_AU (CL2820657)
06-05 00:17:25.450: I/Adreno200-EGL(24203): Build Date: 01/22/13 Tue
06-05 00:17:25.450: I/Adreno200-EGL(24203): Local Branch:
06-05 00:17:25.450: I/Adreno200-EGL(24203): Remote Branch: quic/jb_rel_2.0.3
06-05 00:17:25.450: I/Adreno200-EGL(24203): Local Patches: NONE
06-05 00:17:25.450: I/Adreno200-EGL(24203): Reconstruct Branch: AU_LINUX_ANDROID_JB_REL_2.0.3.04.01.02.21.081 + NOTHING
06-05 00:17:25.940: E/copybit(24203): Error opening frame buffer errno=13 (Permission denied)
06-05 00:17:25.940: W/Adreno200-EGLSUB(24203): <updater_create_surface_state:342>: updater_create_surface_state failed to open copybit, error: -13
06-05 00:17:25.960: D/memalloc(24203): ion: Mapped buffer base:0x53fbc000 size:1536000 offset:0 fd:61
06-05 00:17:25.960: D/memalloc(24203): ion: Mapped buffer base:0x40117000 size:4096 offset:0 fd:63
06-05 00:17:26.300: D/memalloc(24203): ion: Mapped buffer base:0x544dc000 size:1536000 offset:0 fd:66
06-05 00:17:26.300: D/memalloc(24203): ion: Mapped buffer base:0x4011d000 size:4096 offset:0 fd:68
06-05 00:17:28.660: E/copybit(24203): Error opening frame buffer errno=13 (Permission denied)
06-05 00:17:28.660: W/Adreno200-EGLSUB(24203): <updater_create_surface_state:342>: updater_create_surface_state failed to open copybit, error: -13
06-05 00:17:28.670: D/memalloc(24203): ion: Mapped buffer base:0x54753000 size:1536000 offset:0 fd:71
06-05 00:17:28.670: D/memalloc(24203): ion: Mapped buffer base:0x404c5000 size:4096 offset:0 fd:73
06-05 00:17:28.790: D/memalloc(24203): ion: Mapped buffer base:0x54de1000 size:1536000 offset:0 fd:75
06-05 00:17:28.790: D/memalloc(24203): ion: Mapped buffer base:0x4089a000 size:4096 offset:0 fd:77
06-05 00:17:28.820: D/memalloc(24203): ion: Unmapping buffer base:0x53fbc000 size:1536000
06-05 00:17:28.820: D/memalloc(24203): ion: Unmapping buffer base:0x40117000 size:4096
06-05 00:17:28.820: D/memalloc(24203): ion: Unmapping buffer base:0x544dc000 size:1536000
06-05 00:17:28.820: D/memalloc(24203): ion: Unmapping buffer base:0x4011d000 size:4096