如何在Kotlin中将变量从内部类检索到函数

时间:2018-10-29 02:45:47

标签: android kotlin

我正在尝试从内部类Adapter检索testvar值到addtocart函数,但没有得到该值。我可以在Adapter类内检索值,但不能在类外检索值。         代码:

dominic@dom-Inspiron-7559:~/Desktop/Projects/stemletics/stemletics/mysite$ grunt watch
Running "watch" task
Waiting...
>> File "mysite/static/sass/_video.scss" changed.
Running "sass:dist" (sass) task

Done.
Completed in 0.517s at Sun Oct 28 2018 22:36:47 GMT-0400 (EDT) - Waiting...

1 个答案:

答案 0 :(得分:0)

以为您希望在RecyclerView中放置一个按钮。

在这种情况下

内的setOnclicklistener
export class NavbarComponent implements OnInit {

    public loggedIn: boolean;
    public user: any;

    constructor(private _authService: AuthService, private _router: Router) { }

    ngOnInit() {
        this._authService.authStatus
            .subscribe(
                value => {
                    this.loggedIn = value

                }
            );
    }