1
我以前曾問過這個問題,但沒有跟蹤或答案。對不起,我錯過了什麼。以編程方式應用九個補丁程序掛起應用程序
我以編程方式執行EditText二維數組的表格佈局。如果我設置背景顏色,則訂單將被清除。我明白解決方案是九個補丁。我做了一些這在XML佈局很好地工作,但掛在應用程序如下應用:
TableLayout tl = new TableLayout(this);
// tl.setBackgroundColor(0xff498263);
TableRow tr[] = new TableRow[9];
NinePatchDrawable ninenine = (NinePatchDrawable)
getResources().getDrawable(R.drawable.ninenine) ;
// Toast.makeText(this, "getResources is not null",
// Toast.LENGTH_LONG).show();
int x, y;
for (x = 0; x < 9; x++) {
tr[x] = new TableRow(this);
for (y = 0; y < 9; y++) {
entry[x][y] = new EditText(this);
entry[x][y].setText("");
entry[x][y].setWidth(52);
entry[x][y].setEnabled(true);
entry[x][y].setClickable(false);
entry[x][y].setInputType(2);
// entry[x][y].setBackground(ninenine);
entry[x][y].setBackgroundColor(0x880000ff);
程序編譯,但掛起。評論9nine它的工作,但沒有國界。
log.txt的,我不明白:
11-13 10:33:29.730: I/dalvikvm(2155): Could not find method android.widget.EditText.setBackground, referenced from method com.example.test_layout.MainActivity.onCreate
11-13 10:33:29.730: W/dalvikvm(2155): VFY: unable to resolve virtual method 2897: Landroid/widget/EditText;.setBackground (Landroid/graphics/drawable/Drawable;)V
11-13 10:33:29.730: D/dalvikvm(2155): VFY: replacing opcode 0x6e at 0x00b4
11-13 10:33:29.730: D/dalvikvm(2155): VFY: dead code 0x00b7-0113 in Lcom/example/test_layout/MainActivity;.onCreate (Landroid/os/Bundle;)V
11-13 10:33:29.790: D/dalvikvm(2155): GC_EXTERNAL_ALLOC freed 42K, 45% free 2995K/5379K, external 0K/0K, paused 48ms
11-13 10:33:29.810: D/AndroidRuntime(2155): Shutting down VM
11-13 10:33:29.810: W/dalvikvm(2155): threadid=1: thread exiting with uncaught exception (group=0x40139578)
11-13 10:33:29.810: E/AndroidRuntime(2155): FATAL EXCEPTION: main
11-13 10:33:29.810: E/AndroidRuntime(2155): java.lang.NoSuchMethodError: android.widget.EditText.setBackground
11-13 10:33:29.810: E/AndroidRuntime(2155): at com.example.test_layout.MainActivity.onCreate(MainActivity.java:73)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.os.Looper.loop(Looper.java:130)
11-13 10:33:29.810: E/AndroidRuntime(2155): at android.app.ActivityThread.main(ActivityThread.java:3691)
11-13 10:33:29.810: E/AndroidRuntime(2155): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 10:33:29.810: E/AndroidRuntime(2155): at java.lang.reflect.Method.invoke(Method.java:507)
11-13 10:33:29.810: E/AndroidRuntime(2155): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
11-13 10:33:29.810: E/AndroidRuntime(2155): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
11-13 10:33:29.810: E/AndroidRuntime(2155): at dalvik.system.NativeStart.main(Native Method)
11-13 10:33:31.810: I/dalvikvm(2155): threadid=4: reacting to signal 3
11-13 10:33:31.830: I/dalvikvm(2155): Wrote stack traces to '/data/anr/traces.txt'
是源和編譯9個補丁之間的這個問題呢?