相关疑难解决方法(0)

为什么在匿名类中只能访问最终变量?

  1. a只能在这里决赛.为什么?如何aonClick()不将其保留为私有成员的情况下重新分配方法?

    private void f(Button b, final int a){
        b.addClickHandler(new ClickHandler() {
    
            @Override
            public void onClick(ClickEvent event) {
                int b = a*5;
    
            }
        });
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 如何5 * a点击它返回?我的意思是,

    private void f(Button b, final int a){
        b.addClickHandler(new ClickHandler() {
    
            @Override
            public void onClick(ClickEvent event) {
                 int b = a*5;
                 return b; // but return type is void 
            }
        });
    }
    
    Run Code Online (Sandbox Code Playgroud)

java event-handling anonymous-class

341
推荐指数
7
解决办法
11万
查看次数

如何使用不同的参数调用方法?

String从数据库中获取3个值,然后我将其转换为Long然后我正在计算差异,然后将此计算Long值作为参数放入方法中.我正在使用FastAdapter.

filterRequests(List <Long> l)是一种MainActivity基于long来过滤请求/内容的逻辑的方法l.

整个适配器:

public class GRModelClass extends AbstractItem<GRModelClass, GRClass.ViewHolder>{

    private static final ViewHolderFactory<? extends ViewHolder> FACTORY = new ItemFactory();

    String postedBy, postedTime, currentLat, currentLng, utcFormatDateTime, userEmail, userID;
    String startDateTimeInEpoch, endDateTimeInEpoch;
    DatabaseReference primaryDBKey;
    long ms;
    String itemID;

    public GRModelClass(){}

    public GRModelClass(String postedBy, String postedTime, String currentLat, String currentLng, String utcFormatDateTime, String userEmail, String userID, String startDateTimeInEpoch, String endDateTimeInEpoch, DatabaseReference primaryDBKey) {
        this.postedBy = " " …
Run Code Online (Sandbox Code Playgroud)

java methods android instanceof android-context

9
推荐指数
1
解决办法
575
查看次数