EF's Blog

Posts Tagged ‘code

I do not believe you can set the style programatically. To get around this you can create a template layout xml file with the style assigned, for example in res/layout create tvtemplate.xml as with the following content:

<?xml version=”1.0″ encoding=”utf-8″?>

<TextView xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”This is a template”
style=”@style/my_style” />

then inflate this to instantiate your new TextView:

TextView myText = (TextView)getLayoutInflater().inflate(R.layout.tvtemplate, null);

Hope this helps.

How set an object visibility from code :

TextView tvErrorMsg = new TextView();

tvErrorMsg.setVisibility(View.VISIBLE);

or

tvErrorMsg.setVisibility(View.GONE);

String mess = getResources().getString(R.string.mess_1);

EF’s Blog

I'm just ordinary people who lived in an extra-ordinary world.

EF's Blog Stats

  • 135,476 hits
June 2017
M T W T F S S
« Jul    
 1234
567891011
12131415161718
19202122232425
2627282930  

Archives