I have created two buttons (one for an activity,the other for another activity) and i want to open/close one button,then open/close the other.(in the same layout without needing another layout for the other).
我创建了两个按钮(一个用于活动,另一个用于另一个活动),我想打开/关闭一个按钮,然后打开/关闭另一个按钮。(在相同的布局中,不需要另一个布局)。
EDIT:for instance...i want that one button to do an activity which is described in main activity and the other button to do another activity which is described in second activity and is bound to the principal activity.What extend should i use?
编辑:例如...我想要一个按钮来执行主活动中描述的活动,另一个按钮执行另一个活动,这个活动在第二个活动中描述并且绑定到主体活动。我应该使用什么扩展?
How can i do that?
我怎样才能做到这一点?
1 个解决方案
#1
0
If my understanding is right, have a layout which has the two buttons. setContentView()
this layout in both the Activity. Then in Activity A, setVisibility=GONE
for first button and in Activity B, setVisibility=GONE
for the second button. So this way you can reuse the same layout in both activities.
如果我的理解是正确的,那么有一个具有两个按钮的布局。 setContentView()这个布局都在Activity中。然后在活动A中,第一个按钮的setVisibility = GONE,第二个按钮的setVisibility = GONE,第二个按钮的setVisibility = GONE。因此,您可以在两个活动中重复使用相同的布局。
If you don't want to hide the buttons, but want to have different behaviors for these buttons in different activity, then just attach an onClickListener to the buttons and override the onClick() in each of the activity.
如果您不想隐藏按钮,但希望在不同活动中对这些按钮具有不同的行为,则只需将onClickListener附加到按钮并覆盖每个活动中的onClick()。
#1
0
If my understanding is right, have a layout which has the two buttons. setContentView()
this layout in both the Activity. Then in Activity A, setVisibility=GONE
for first button and in Activity B, setVisibility=GONE
for the second button. So this way you can reuse the same layout in both activities.
如果我的理解是正确的,那么有一个具有两个按钮的布局。 setContentView()这个布局都在Activity中。然后在活动A中,第一个按钮的setVisibility = GONE,第二个按钮的setVisibility = GONE,第二个按钮的setVisibility = GONE。因此,您可以在两个活动中重复使用相同的布局。
If you don't want to hide the buttons, but want to have different behaviors for these buttons in different activity, then just attach an onClickListener to the buttons and override the onClick() in each of the activity.
如果您不想隐藏按钮,但希望在不同活动中对这些按钮具有不同的行为,则只需将onClickListener附加到按钮并覆盖每个活动中的onClick()。