我想知道是否会有一个方法来分享让我们说像这样的OnSeekBarChangeListener:
SeekBar.OnSeekBarChangeListener SeekBarCarChanged = new
SeekBar.OnSeekBarChangeListener() {..}
具有相同ID的相同搜索栏的不同活动之间。 我想实现这个目标
ActivityClass1
setOnSeekBarChangeListener for seekbar in activity1..Get the Listener method from a third class
ActivityClass2
setOnSeekBarChangeListener for seebar in activity2.. Get the Listener method from the same third class
答案 0 :(得分:1)
好吧,让我们看看,
获取一个ActivityClass1类,它扩展Activity并在此类中实现seekbarlistener
class ActivityClass1 extends Activity {
SeekBar.OnSeekBarChangeListener SeekBarCarChanged = new
SeekBar.OnSeekBarChangeListener() {..}
}
然后获取你想要这个监听器的类,并将ActivityClass1扩展到它们,例如:
// I want to access the SeekBarCarChanged listeners in the following classes
class ActivityClass2 extends ActivityClass1 {...}
class ActivityClass3 extends ActivityClass1 {...}
依旧......