請給我一個關於以下問題的建議。如何覆蓋方法內的Runnable?
我有A類& B類 如何覆蓋類B中的foo方法中的Runnable?
class A {
//some code
.......
protected void foo() {
//some code
.......
//adding click listener to instance of MyButton
myButton.show(new Runnable(){
@Override
public void run() {
.......
}
});
//some code
.......
}
//some code
.......
}
class B extends A {
@Override
protected void foo() {
super.foo();
//some NEW code
.......
//adding click listener to instance of MyButton
myButton.show(new Runnable(){
@Override
public void run() {
//Copied&Pasted old code
.......
//NEW code
.......
}
});
}
}
我可以不復制&從超級粘貼現有代碼的新代碼添加到按鈕的處理程序(可運行在myButton的)?怎麼樣?
什麼是myButton的訪問符? – SMA 2015-04-02 09:04:09