我有2个按钮邀请和共享,如果我单击邀请,则会出现包含4个imageviews的linearlayout bar1,对于共享按钮,在这4个imageview选项中也将显示相同的linearlayout bar2,如果我单击邀请和共享按钮,则布局栏均会出现,但是对我来说,当我单击“邀请”或共享时,一次只能显示一个对应的栏...
if I understand you correctly something like this will do the trick:
invite.setOnClickListener(new OnClickListener(){
public void onClick(View v){
linearlayoutbar1.setVisibility(View.VISIBLE);
linearlayoutbar2.setVisibility(View.GONE);
}
});
share.setOnClickListener(new OnClickListener(){
public void onClick(View v){
linearlayoutbar2.setVisibility(View.VISIBLE);
linearlayoutbar1.setVisibility(View.GONE);
}
});
Insert LinearyLayout upon your requirements
<merge>
<LinearLayout
android:id="@+id/main"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:visibility="gone"
/>
<LinearLayout
android:id="@+id/sub"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:visibility="gone"
/>
</merge>
depending upon your invite and share button you can put these code invite.setOnClickListener() or share.setOnClickListener()
Insert Visibility of LinearLayout according to your Logic
LinearLayout mainLayout=(LinearLayout)this.findViewById(R.id.main);
LinearLayout subLayout=(LinearLayout)this.findViewById(R.id.sub);
invite.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
mainLayout.setVisibility(View.VISIBLE);
}
});
share.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
subLayout.setVisibility(View.VISIBLE);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.