Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid add border to edit text programmatically
    primarykey
    data
    text
    <p>I used <a href="https://stackoverflow.com/questions/1598119/is-there-an-easy-way-to-add-a-border-to-the-top-and-bottom-of-an-android-view">this</a> example and tried to add it to my edit text programmatically like <code>editText.setBackgroundResource(R.drawable.edit_text_back);</code>, but it does not work. How can I accomplish this? Any suggestions or ideas?</p> <p><strong>EDIT</strong> The editText is defined programmatically as well. </p> <pre><code>EditText editText = new EditText(this.getApplicationContext()); </code></pre> <p>I added this to a table row</p> <p><strong>TRIED</strong></p> <pre><code>editText.setBackground(getResources().getDrawable(R.drawable.edit_text_back)); editText.setBackgroundDrawable(getResources().getDrawable(R.drawable.edit_text_back)); </code></pre> <p><strong>EDIT TEXT CREATION</strong></p> <pre><code>TableRow row = (TableRow) findViewById(R.id.table_row_kind); TableRow.LayoutParams rowP = new TableRow.LayoutParams(); rowP.setMargins(10, 0, 0, 0); editText = new EditText(this.getApplicationContext()); editText .setGravity(Gravity.FILL_HORIZONTAL); editText .setLayoutParams(rowP); editText .setFilters(new InputFilter[]{txtFilter}); editText.setBackground(getResources().getDrawable(R.drawable.edit_text_back)); </code></pre> <p>row.xml</p> <pre><code>&lt;TableRow android:id="@+id/table_row_kind" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dip" &gt; &lt;TextView android:layout_width="250sp" android:text="Kind" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/TableRow&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload