在Switch(view v)中获取当前操作对象

小细节,作用很大,不知道就很头疼,这也是在csdn中其他writer中看到的,多看书是好的。

public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.addmess_item_yes:
            Button b=(Button) v;
            b.setText("已同意");

假如按的是TextView,那就Textview b=(Button) v;

猜你喜欢

转载自blog.csdn.net/jian11058/article/details/80832109
今日推荐