Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set text of included view

I'm wondering if this is possible:

In a layout file, I've included a view:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include 
        layout="@layout/includedView" />

</LinearLayout>

That includedView contains this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="48dip" >

    <ImageView
    ...
    />

    <TextView
    ....
    />

</RelativeLayout>

My question is: is it possible to set the text for the textview inside the includedView from the layout that includes the view (so from layout 1)?

Hope my question is clear, if not, then please ask.

like image 941
Xander Avatar asked Apr 15 '13 09:04

Xander


1 Answers

you can do that from code as same as single layout. for example

setContentView(R.layout.first_layout);
TextView tv = (TextView)findViewById(R.id.textview_of_second_layout); // just like single layout
tv.setText(something);

But I think it is not possible to do this from the first layout xml as there is no visible way. (someone corrects me if I am wrong)

like image 150
stinepike Avatar answered Nov 14 '22 05:11

stinepike