How do you implement complex UI presentation and click event binding?

for example, a UI is particularly complex and will show text in four cases, where click events are not the same.

void updateUI() {
    if (mIsA) {
        if (mIsB) {
            mTextView.setText("111111");
        } else {
            mTextView.setText("33333");
        }
    } else {
        if (mIsC) {
            mTextView.setText("222222");
        } else {
            mTextView.setText("444444");
        }
    }
}

it would be too repetitive if I wrote exactly the same judgment on the click event.

onClick(View v) {
    if (mIsA) {
        if (mIsB) {
            // do thing 11111
        } else {
            // do thing 3333333
        }
    } else {
        if (mIsC) {
            // do thing 222222
        } else {
            // do thing 44444
        }
    }   
}

the way I want to do this is to update the UI and deal with the UI presentation with different onclicklistener on the corresponding settings


use switch, to judge mTextView.getText () Chinese case


answer your own questions. I now think the better way is

.
void updateUI() {
    mTextView.setOnClickListener(null);
    if (mIsA) {
        if (mIsB) {
            mTextView.setText("111111");
            mTextView.setOnClickListener(mClickListener1);
        } else {
            mTextView.setText("33333");
            mTextView.setOnClickListener(mClickListener3);
        }
    } else {
        if (mIsC) {
            mTextView.setText("222222");
            mTextView.setOnClickListener(mClickListener2);
        } else {
            mTextView.setText("444444");
            mTextView.setOnClickListener(mClickListener4);
        }
    }
}

OnClickListener mClickListener1 = new OnClickListener() {
    void onClick() {
        // do thing 11111
    }
};

OnClickListener mClickListener2 = new OnClickListener() {
    void onClick() {
        // do thing 22222
    }
};

OnClickListener mClickListener3 = new OnClickListener() {
    void onClick() {
        // do thing 33333
    }
};

OnClickListener mClickListener4 = new OnClickListener() {
    void onClick() {
        // do thing 44444
    }
};
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a5e1-2b755.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a5e1-2b755.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?