다른보기를 표시하는 버튼이있는 레이아웃이 있지만 한 번만 버튼을 클릭하면 사라지고 다른보기가 표시됩니다. 두 번째로 해당 버튼의 상위보기를 클릭해야합니다. 다른보기 (표시된보기)가 사라지고 단추가 다시 나타납니다. 나는 노력 clickable:false
하고 focusable:false
있지만 작동하지 않습니다. 어떻게 할 수 있습니까?
관련 코드
XML
<LinearLayout
android:id="@+id/item_tournament_header"
android:background="@drawable/bg_card_tournament"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="15">
<RelativeLayout
android:clickable="false"
android:focusable="false"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="match_parent">
<com.github.siyamed.shapeimageview.CircularImageView
android:id="@+id/item_friend_img_profile_pic"
android:layout_height="48dp"
android:layout_width="48dp"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:src="@drawable/ic_profile"
app:siBorderColor="@color/white"/>
</RelativeLayout>
<LinearLayout
android:clickable="false"
android:focusable="false"
android:layout_weight="10"
android:layout_width="0dp"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:id="@+id/tournament_name"
android:textSize="@dimen/text_h3"
android:textStyle="bold"
android:textColor="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tournament_client"
android:textSize="@dimen/text_p"
android:textColor="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<RelativeLayout
android:clickable="false"
android:focusable="false"
android:layout_weight="2"
android:layout_width="0dp"
android:orientation="vertical"
android:layout_height="match_parent">
<ImageView
android:id="@+id/btn_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_plus_tournaments"/>
</RelativeLayout>
</LinearLayout>
자바
btn_plus = (ImageView) findViewById(R.id.btn_plus);
TournamentContent =(LinearLayout)findViewById(R.id.item_tournament_content);
TournamentHeadaer =(LinearLayout)findViewById(R.id.item_tournament_header);
btn_plus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TournamentContent.setVisibility(View.VISIBLE);
btn_plus.setVisibility(View.GONE);
}
});
TournamentHeadaer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(btn_plus.getVisibility()==View.VISIBLE)
{
// It's not entering here!!!
TournamentContent.setVisibility(View.GONE);
btn_plus.setVisibility(View.VISIBLE);
}
}
});
어쩌면 내가 미스는 문제를 이해하지만 난 당신의 문제의 논리라고 생각 if
문 : if(btn_plus.getVisibility()==View.VISIBLE)
그이어야한다 : if(TournamentContent.getVisibility()==View.VISIBLE)
또는if(btn_plus.getVisibility()==View.GONE)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다