0

RelativeLayout私は2 つTextViewの単純なとImageView. ビューの可視性を に設定すると、ビューをView.INVISIBLEクリックしたときに親の onClickListener が起動されません。それらが表示されると、クリックするたびに親の onClickListener が呼び出されます。モデルの状態によっては
別の写真を撮りたいので非表示にしたいです。TextView私は何が欠けていますか?

 public class CheckinCompoundView extends RelativeLayout {

    private static final String TAG = CheckinCompoundView.class.getSimpleName();
    private RelativeLayout mEventContainer;
    @SuppressWarnings("unused")
    private ImageView mEventIcon;
    private TextView mEventName;
    private TextView mEventCategory;
    private RelativeLayout mPlaceContainer;
    private ImageView mPlaceIcon;
    private TextView mPlaceName;
    private TextView mPlaceCategory;
    // private TextView mPlaceEmptyView;
    private TextView mStatText;

    public CheckinCompoundView(Context context) {
        super(context);
        initView();
    }

    private void initView() {
        Context context = getContext();
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.view_checkin_compund_view, this, true);

        mEventContainer = (RelativeLayout) findViewById(R.id.event_container);
        mEventIcon = (ImageView) findViewById(R.id.event_image);
        mEventName = (TextView) findViewById(R.id.event_title);
        mEventCategory = (TextView) findViewById(R.id.event_category);
        mPlaceContainer = (RelativeLayout) findViewById(R.id.place_container);
        mPlaceIcon = (ImageView) findViewById(R.id.place_image);
        mPlaceName = (TextView) findViewById(R.id.place_title);
        mPlaceCategory = (TextView) findViewById(R.id.place_category);
        mStatText = (TextView) findViewById(R.id.stat_text);
        // mPlaceEmptyView = (TextView) findViewById(R.id.place_empty);

        mEventCategory.setTypeface(UIUtils.getRobotoLight(context));
        mPlaceCategory.setTypeface(UIUtils.getRobotoLight(context));
        mEventName.setTypeface(UIUtils.getRobotoCondensed(context));
        mPlaceName.setTypeface(UIUtils.getRobotoCondensed(context));
        mStatText.setTypeface(UIUtils.getRobotoCondensed(context));
        // mPlaceEmptyView.setTypeface(UIUtils.getRobotoLight(context));
    }

    private void showEmpty() {
        // mPlaceEmptyView.setVisibility(View.VISIBLE);
        mPlaceIcon.setVisibility(View.INVISIBLE);
        mPlaceName.setVisibility(View.INVISIBLE);
        mPlaceCategory.setVisibility(View.INVISIBLE);
    }

    private void hideEmpty() {
        // mPlaceEmptyView.setVisibility(View.GONE);
         mPlaceIcon.setVisibility(View.VISIBLE);
         mPlaceName.setVisibility(View.VISIBLE);
         mPlaceCategory.setVisibility(View.VISIBLE);
    }

     public void setOnPlaceClickListener(OnClickListener listener) {
        mPlaceCategory.setOnClickListener(listener);
    }
    }

そして対応するレイアウト:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/light_grey_background_border"
    tools:context=".view.CheckinPlaceCompoundView" >

    <RelativeLayout
        android:id="@+id/event_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:minHeight="@dimen/view_chckn_compnd_event_minHeight"
        android:padding="@dimen/view_chckn_compnd_padding" >

        <ImageView
            android:id="@+id/event_image"
            android:layout_width="@dimen/view_chckn_compnd_event_iconHeight"
            android:layout_height="@dimen/view_chckn_compnd_event_iconHeight"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:scaleType="centerInside"
            android:src="@drawable/ph_abstract_100_100_2" />

        <TextView
            android:id="@+id/event_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/event_image"
            android:layout_marginLeft="@dimen/view_chckn_compnd_event_padding"
            android:layout_toRightOf="@+id/event_image"
            android:maxLines="1"
            android:text="SZOFTVER LABORATORIUM 4."
            android:textSize="16sp" />

        <TextView
            android:id="@+id/event_category"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/event_title"
            android:layout_below="@+id/event_title"
            android:maxLines="1"
            android:text="General"
            android:textColor="@color/text_grey" />
    </RelativeLayout>


    <RelativeLayout
        android:id="@+id/place_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/event_container"
        android:layout_below="@+id/event_container"
        android:minHeight="@dimen/view_chckn_compnd_event_minHeight"
        android:padding="@dimen/view_chckn_compnd_padding" >

        <ImageView
            android:id="@+id/place_image"
            android:layout_width="@dimen/view_chckn_compnd_place_iconHeight"
            android:layout_height="@dimen/view_chckn_compnd_place_iconHeight"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:scaleType="centerInside"
            android:src="@drawable/ph_abstract_100_100_2" />

        <TextView
            android:id="@+id/place_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/place_image"
            android:layout_marginLeft="@dimen/view_chckn_compnd_event_padding"
            android:layout_toRightOf="@+id/place_image"
            android:maxLines="1"
            android:text="IB028"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/place_category"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/place_title"
            android:layout_below="@+id/place_title"
            android:maxLines="1"
            android:text="Labratory"
            android:textColor="@color/text_grey" />
    </RelativeLayout>

    <TextView
        android:id="@+id/stat_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/place_container"
        android:layout_below="@+id/place_container"
        android:minHeight="@dimen/view_chckn_compnd_event_minHeight"
        android:padding="@dimen/view_chckn_compnd_padding"
        android:text="Your team is dominating" />
    </RelativeLayout>
4

1 に答える 1

1

showEmpty() メソッドとhideEmpty()メソッドを次のように変更します。

private void showEmpty() {
    // mPlaceEmptyView.setVisibility(View.GONE);
    mPlaceIcon.setVisibility(View.GONE);
    mPlaceName.setVisibility(View.GONE);
    mPlaceCategory.setVisibility(View.GONE);
    mPlaceIcon.setClickable( false );
    mPlaceName.setClickable( false );
    mPlaceCategory.setClickable( false );

}


private void hideEmpty() {
    // mPlaceEmptyView.setVisibility(View.GONE);
     mPlaceIcon.setVisibility(View.VISIBLE);
     mPlaceName.setVisibility(View.VISIBLE);
     mPlaceCategory.setVisibility(View.VISIBLE);
     mPlaceIcon.setClickable( true);
     mPlaceName.setClickable( true);
     mPlaceCategory.setClickable( true);
}
于 2013-01-16T06:57:27.860 に答える