开发者

Android ,Calling buttons from include tag

开发者 https://www.devze.com 2023-01-13 21:42 出处:网络
I followed @seanhodges sample of the footer bar (android navigation bar bottom) : https://stackoverflow.com/questions/2369975?tab=votes#tab-top

I followed @seanhodges sample of the footer bar (android navigation bar bottom) : https://stackoverflow.com/questions/2369975?tab=votes#tab-top

Is it possible to call it from include tag and then access each button at runtime

<LinearLayout android:layout_alignParentBottom="true"
    android:layout_height="wrap_content" android:layout_width="fill_parent">
     <include  android:id="@+id/footer" layout="@layout/footer" /> 
</LinearLayout>

when calling it from the include tag, it looks good on the screen. I try reach the buttons at run time but could get it work..

I know this is not the way but I am looking for something like this...

 Button _BackButton= (Button)findViewById(R.id.footer);

_BackButton.setText("new text");

 Button _Backhome= (Button)findViewById(R.id.footer);

_Backh开发者_高级运维ome.setText("new text");

can it be done through the -include- tag?

thanks


You should use the ids of the buttons from within the footer layout, using the example you linked to you can get the back button by doing this:

Button _BackButton= (Button)findViewById(R.id.back);

The View hierarchy will be sure to go through the included view when looking for a specified id.

0

精彩评论

暂无评论...
验证码 换一张
取 消