java - How to reference TextViews inside embed LinearLayout? -


i have linearlayout layout resource file (xml) has multiple linearlayouts of different orientations embedded inside. inside 1 of these embedded linearlayouts have textviews want change dynamically java code, reason, when ever try , set id these textviews, throws error. know what's causing this? also, there fix or alternate way access these textviews within embedded linearlayout? in advance.

edit: nevermind, feel idiot. forgot "@+id/" sorry if wasted time people. guess have been coding bit last 4 days. have been till 2:00 every day

you should able assign id each textview inside xml layout file. if haven't explicitly declared appropriate id resources (the usual case), need use special syntax:

<textview android:id="@+id/view_id . . . /> 

the @+ syntax automatically create id of indicated name if none exists. (see docs android:id.)

if use syntax:

<textview android:id="@id/view_id . . . /> 

then need explicitly have id resource created (in res/values/any_file.xml):

<item type="id" name="view_id" /> 

see docs on id resources.

whichever method use, can textview in code using:

textview tv = (textview) findviewbyid(r.id.view_id); 

p.s. after seeing code, problem clear: error message says, cannot use string view id. so, instance, need replace android:id="limval" android:id="@+id/limval" , throughout layout file. in code can use

textview limvalview = (textview) findviewbyid(r.id.limval); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -