Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:31:54+00:00 2026-06-14T11:31:54+00:00

I have asked this question before but without a trace or answer. Sorry if

  • 0

I have asked this question before but without a trace or answer. Sorry if I missed something.

I do a table layout of a 2D array of EditText programmatically. If I set the background color the orders are wiped out. I understand the solution is a nine patch. I have made several which work well in XML layouts but hang the app when applied programmatically as follows:

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);

The program compiles but hangs. Commenting out ninenine it works but no borders.

log.txt which I do not understand:

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'

Is this problem between source and compiled nine patch?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:31:55+00:00Added an answer on June 14, 2026 at 11:31 am

    What is the version of Android which you’re using to test when you get that error?

    setBackground(Drawable background) is only available from API 16 onwards. If the minSdkVersion is lower than that but targetSdkVersion is 16 it will compile OK but will fail on lower Android versions at run-time.

    In that case, use setBackgroundDrawable(Drawable background) instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asked this question before but did not get the satisfied answer as
This question may have been asked before, but I had trouble finding an answer,
I have asked a question like this before, and the answer was great but
I have asked this before but I didn't get the question right so the
No doubt elements of this question have been asked before, but I'm having trouble
I know variants of this question have been asked before (even by me), but
I've asked this question before but couldn't get the answer I was looking for
I already asked this question before, but without any good response, my problem is
This question has been asked before but 1) the user never accepted an answer
I realize this question is very likely to have been asked before, but I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.