1

私は拡張するカスタムビューを持っていますLinearLayout:

public class CustomEditTextLogin extends LinearLayout {
    public CustomEditTextLogin(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        initialize(context);
    }
    public CustomEditTextLogin(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
        initialize(context);
    }
    private LinearLayout llParentCetL;
    private TextView txtAlertCs;
    private EditText edt;
    private ImageView img;
    public static final int TEXT = 0;
    public static final int EMAIL = 1;
    public static final int PASSWORD = 2;
    public static final int USERNAME = 3;
    private void initialize(Context context) {
        LayoutInflater mLayoutInflater = (LayoutInflater)
        context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = mLayoutInflater.inflate(R.layout.custom_edit_text_login, this, true);
        llParentCetL = (LinearLayout) view.findViewById(R.id.llParentCetL);
        txtAlertCs = (TextView) view.findViewById(R.id.txtAlertCetL);
        edt = (EditText) view.findViewById(R.id.edtCetL);
        img = (ImageView) view.findViewById(R.id.imgCetL);

        txtAlertCs.setVisibility(View.GONE);
        int imgMargin = (int) (UIHelpers.width *0.025);
        UIHelpers.setMargin(img, imgMargin, imgMargin, imgMargin, imgMargin);
        img.setOnClickListener(new OnClickListener() {   
            @Override
            public void onClick(View view) {
                setFocus();
            }
        });
        public CustomEditTextLogin setFocus(){
            if(edt != null){
                edt.setFocusableInTouchMode(true);
                edt.requestFocus();

                InputMethodManager imm = (InputMethodManager) App.context.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(edt, InputMethodManager.SHOW_IMPLICIT);
            }
            return this;
        }
    }

インスタンスの状態を保存して復元したいのですが、アクティビティのインスタンスの状態と異なります。

Androidのカスタムビューでインスタンスの状態を保存するには?

4

1 に答える 1