使用通用布局和事件的所有活动 [英] using common Layout and its event in all activities

查看:149
本文介绍了使用通用布局和事件的所有活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有四个按钮,最上面一栏,我使用的所有活动此布局由其中一个共同的布局,在所有的活动布局通用布局 通过

I have one common layout that has four button at top bar and i am using this layout in all activities by including that common layout in all activities layout by

<包括...>

不过,我必须使用4个按钮单击事件中的所有活动 有没有comman方法来创建用于一切活动都定制actvity,我对活动的创建和实施该活动的4按钮单击事件,并扩展在所有actvity的活动,但它不是为我工作。 请给我一些想法的。 谢谢

But i have to use that 4 buttons click event in all activities is there any comman way to create custom actvity that is used in all activites , i have created on activity and implement that 4 button click event in that activity and extends that activity in all actvity but it is not working for me. please give me some idea for that. Thanks

推荐答案

是的,你可以做一个活动说的 HeaderActivity

yes,You can make one activity say HeaderActivity

的onCreate的setContentView(R.layout.header); header.xml

和写你在这个类中的所有按钮的Click事件一次,

and write your all Button Click events in this class once and

和现在的其他活动扩展HeaderActivity。 喜欢,

and now in other Activities extend HeaderActivity. like,

public class SecondActivity extends HeaderActivity
{
}

要显示不同的布局。

放的LinearLayout在下面的按钮header.xml和相互活动中使用

put a LinearLayout in header.xml below that buttons and in each other activities use

ViewGroup vg = (ViewGroup) findViewById(R.id.lldata);
ViewGroup.inflate(getApplicationContext(), R.layout.listwitter, vg);

下面的 lldata是的LinearLayout在header.xml

要显示差异活性不同的布局。

to show different layout in diff activity.

这篇关于使用通用布局和事件的所有活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆