gpt4 book ai didi

java - 如何扩展和修改不同包 java 中的类 - 里面有解释

转载 作者:太空宇宙 更新时间:2023-11-04 12:09:39 25 4
gpt4 key购买 nike

我需要修改来自不同包的类中的方法

包结构

Android应用程序 ---

         -- dependencies " materialSheetFab"

materialSheetFab ---

               -- src
...
--MaterialSheetAnimation.class

---MaterialSheetFab

materialSheetAnimation下,我需要覆盖

public void alignSheetWithFab(View fab) {
....

if (rightDiff != 0) { // need to remove this block of code
.....
}

该方法在MaterialSheetFab中调用

protected void morphIntoSheet(final AnimationListener endListener) {

// Align sheet's position with FAB
sheetAnimation.alignSheetWithFab(fab);

问题是materialsheetAnimation中的成员变量是私有(private)的,所以

public class Sample extend MaterialSheetAnimat{
......
@overide
public void AlignSheetWithFab(Fab){
....
//remove code
// but cant call any instance variable there all private
// sheet is private member // sheet.setX(fab.coord[0]; not possible

即使扩展类也不允许我重写我感兴趣的代码块

最佳答案

Bbut the problem is member variable in the materialsheetAnimation are private so even extending the class doesnt allow me to rewrite the code block am intereested in

这是private成员的定义,您不能覆盖它。

关于java - 如何扩展和修改不同包 java 中的类 - 里面有解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39973376/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com