I used this example and tried to add it to my edit text programmatically like editText.setBackgroundResource(R.drawable.edit_text_back);
, but it does not work. How can I accomplish this? Any suggestions or ideas?
EDIT The editText is defined programmatically as well.
EditText editText = new EditText(this.getApplicationContext());
I added this to a table row
TRIED
editText.setBackground(getResources().getDrawable(R.drawable.edit_text_back));
editText.setBackgroundDrawable(getResources().getDrawable(R.drawable.edit_text_back));
EDIT TEXT CREATION
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));
row.xml
<TableRow
android:id="@+id/table_row_kind"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip" >
<TextView
android:layout_width="250sp"
android:text="Kind"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>