I've tried this solution and worked fine in XML, But how I can do the samething via code ?
Actually I wanna change edittext (theme: lable, text color, line color) on press of a button.
I've tried this solution and worked fine in XML, But how I can do the samething via code ?
Actually I wanna change edittext (theme: lable, text color, line color) on press of a button.
In Android changing the style after creating the view is not supported. That is you can't set a style to the view dynamically. But what you can do is create that view in xml, set the style you want in the xml only and when you want to show a view, you inflate it. e.g.
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a template"
style="@style/my_style" />
and now inflate tis view wherever you want to use as,
TextView myText = (TextView)getLayoutInflater().inflate(R.layout.tvtemplate, null);