0

ビュー用に別のクラスを作成しました。ユーザーの要求に応じていくつかのフィールドを表示/非表示にする必要がある場所。しかし、setvisible(View.GONE) と setVisible(View.Invisible) は機能しません。

無効化を使用して試しましたが、結果は同じです。

@Override
public View view() {
    LayoutInflater inflater1 = LayoutInflater.from(currentActivity);
    View row = inflater1.inflate(R.layout.personal_form, null);

    ed_name = (EditText) row.findViewById(R.id.ed_name);
    ed_email = (EditText) row.findViewById(R.id.ed_email);
    ed_phone = (EditText) row.findViewById(R.id.ed_phone);
    ed_address = (EditText) row.findViewById(R.id.ed_address);
    ed_zipcode = (EditText) row.findViewById(R.id.ed_zip_code);
    ed_title = (EditText) row.findViewById(R.id.ed_title);
    ed_country = (EditText) row.findViewById(R.id.ed_country);

    ImageView img_name = (ImageView) row.findViewById(R.id.img_name);
    ImageView img_email = (ImageView) row.findViewById(R.id.img_email);
    ImageView img_phone = (ImageView) row.findViewById(R.id.img_phone);
    ImageView img_address = (ImageView) row.findViewById(R.id.img_address);
    ImageView img_zipcode = (ImageView) row.findViewById(R.id.img_zip_code);
    ImageView img_title = (ImageView) row.findViewById(R.id.img_title);
    ImageView img_country = (ImageView) row.findViewById(R.id.img_country);

    RelativeLayout layout_oned = (RelativeLayout) row.findViewById(R.id.relative_one);
    RelativeLayout layout_twod = (RelativeLayout) row.findViewById(R.id.relative_two);
    RelativeLayout layout_threed = (RelativeLayout) row.findViewById(R.id.relative_three);
    RelativeLayout layout_fourd = (RelativeLayout) row.findViewById(R.id.relative_four);
    RelativeLayout layout_fived = (RelativeLayout) row.findViewById(R.id.relative_five);
    RelativeLayout layout_sixd = (RelativeLayout) row.findViewById(R.id.relative_six);
    RelativeLayout layout_sevend = (RelativeLayout) row.findViewById(R.id.relative_seven);
    RelativeLayout layout_eightd = (RelativeLayout) row.findViewById(R.id.relative_eight);

    ImageView header_imag_one = (ImageView) row.findViewById(R.id.icon);
    ImageView header_imag_two = (ImageView) row.findViewById(R.id.image_id);
    ImageView header_imag_three = (ImageView) row.findViewById(R.id.image_id_two);
    TextView header_tv = (TextView) row.findViewById(R.id.title);

    header_imag_one.setImageResource(R.drawable.ic_launcher);
    header_tv.setText("string_one");

    if (bool) {
        header_imag_three.setVisibility(View.VISIBLE);
        header_imag_two.setVisibility(View.GONE);

        ed_name.setVisibility(View.VISIBLE);
        ed_email.setVisibility(View.VISIBLE);
        ed_phone.setVisibility(View.VISIBLE);
        ed_address.setVisibility(View.VISIBLE);
        ed_zipcode.setVisibility(View.VISIBLE);
        ed_title.setVisibility(View.VISIBLE);
        ed_country.setVisibility(View.VISIBLE);

        // ed_name.setText(StaticInfo.personalInfoBean.name);
        // ed_email.setText(StaticInfo.personalInfoBean.email_id);
        // ed_phone.setText(StaticInfo.personalInfoBean.phone);
        // ed_address.setText(StaticInfo.personalInfoBean.address);
        // ed_zipcode.setText(StaticInfo.personalInfoBean.zip_code);
        // ed_title.setText(StaticInfo.personalInfoBean.title);
        // ed_country.setText(StaticInfo.personalInfoBean.country);

        img_name.setVisibility(View.VISIBLE);
        img_email.setVisibility(View.VISIBLE);
        img_phone.setVisibility(View.VISIBLE);
        img_address.setVisibility(View.VISIBLE);
        img_zipcode.setVisibility(View.VISIBLE);
        img_title.setVisibility(View.VISIBLE);
        img_country.setVisibility(View.VISIBLE);

        layout_oned.setVisibility(View.VISIBLE);
        layout_twod.setVisibility(View.VISIBLE);
        layout_threed.setVisibility(View.VISIBLE);
        layout_fourd.setVisibility(View.VISIBLE);
        layout_fived.setVisibility(View.VISIBLE);
        layout_sixd.setVisibility(View.VISIBLE);
        layout_sevend.setVisibility(View.VISIBLE);
        layout_eightd.setVisibility(View.VISIBLE);
    } else {
        header_imag_three.setVisibility(View.GONE);
        header_imag_two.setVisibility(View.VISIBLE);

        ed_name.setVisibility(View.GONE);
        ed_email.setVisibility(View.GONE);
        ed_phone.setVisibility(View.GONE);
        ed_address.setVisibility(View.GONE);
        ed_zipcode.setVisibility(View.GONE);
        ed_title.setVisibility(View.GONE);
        ed_country.setVisibility(View.GONE);

        img_name.setVisibility(View.GONE);
        img_email.setVisibility(View.GONE);
        img_phone.setVisibility(View.GONE);
        img_address.setVisibility(View.GONE);
        img_zipcode.setVisibility(View.GONE);
        img_title.setVisibility(View.GONE);
        img_country.setVisibility(View.GONE);

        layout_oned.setVisibility(View.GONE);
        layout_twod.setVisibility(View.GONE);
        layout_threed.setVisibility(View.GONE);
        layout_fourd.setVisibility(View.GONE);
        layout_fived.setVisibility(View.GONE);
        layout_sixd.setVisibility(View.GONE);
        layout_sevend.setVisibility(View.GONE);
        layout_eightd.setVisibility(View.GONE);
    }
    row.invalidate();
    header_tv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (bool) {
                bool = false;
                submit_request();
            } else {
                bool = true;
            }
            view();
        }
    });
    return row;
}
4

1 に答える 1

0

yourView.setVisibility(View.INVISIBLE)代わりに試してくださいyourView.setVisible(View.Invisible)

于 2013-05-22T18:16:00.133 に答える