在NearablesDemoActivity.java中添加什么方法

时间:2015-10-26 04:54:43

标签: java android estimote

我正在制作一个使用estimote贴纸并面临一些问题的鞋贴纸项目。我在我的项目中使用android studio

我在 dbRow = stickerdb.getResult(currentNearable.identifier(" 065473d63cd9d687"))时出错;

说预期方法调用

错误日志: 错误:(96,52)错误:找不到符号方法标识符(String)

public class NearablesDemoActivity extends BaseActivity {

private static final String TAG = NearablesDemoActivity.class.getSimpleName();

private Nearable currentNearable;
private BeaconManager beaconManager;
private String scanId;

TextView Desc;  //description
Spinner spinnerDropDown;  //for size available
String[] size = {
};                   //for size available
Spinner spinnerDropDown2;   //for colours available
String[] colour = {
};                      //for colours available
TextView COO;      //For country of origin
TextView SM; //For Shoe Model
TextView Price; //For price
Button btnRating;  //for button
private Database_sticker stickerdb;
Sresult dbRow;

@Override
protected int getLayoutResId() {
    return R.layout.nearable_demo;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.nearable_demo);


    currentNearable = getIntent().getExtras().getParcelable(ListNearablesActivity.EXTRAS_NEARABLE);
    displayCurrentNearableInfo();

    beaconManager = new BeaconManager(this);

    ArrayAdapter<String> adapter= new ArrayAdapter<>(this,android.R.layout.simple_spinner_dropdown_item ,size);  //for size available
    spinnerDropDown.setAdapter(adapter);
    ArrayAdapter<String> adapter1= new ArrayAdapter<>(this,android.R.layout.simple_spinner_dropdown_item ,colour); //for colours available
    spinnerDropDown2.setAdapter(adapter1);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_action_navigation_arrow_back);
    toolbar.setTitle(getTitle());
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    btnRating=(Button)findViewById(R.id.rd);

    btnRating.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent pageforRatingBar = new Intent(getApplicationContext(), RatingBar_main.class);
            startActivity(pageforRatingBar);
        }
    });

    stickerdb = new Database_sticker(this);
   // dbRow = stickerdb.getResult(1);//currentNearable.identifier()
    dbRow = stickerdb.getResult(currentNearable.identifier("065473d63cd9d687"));
    dbRow.getSa();
    dbRow.getDesc();
    dbRow.getCoo();
    dbRow.getId();
    dbRow.getPrice();
    dbRow.getSm();
}

@Override
protected void onResume() {
    super.onResume();
    beaconManager.setNearableListener(new BeaconManager.NearableListener() {
        @Override
        public void onNearablesDiscovered(List<Nearable> nearables) {
            updateCurrentNearable(nearables);
            displayCurrentNearableInfo();

        }
    });


    beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
        @Override
        public void onServiceReady() {
            scanId = beaconManager.startNearableDiscovery();
        }
    });
}

@Override
protected void onStop() {
    beaconManager.disconnect();
    super.onStop();
}

private void displayCurrentNearableInfo() {
            Desc = (TextView) findViewById(R.id.textview1);   //for description
            // Get reference of SpinnerView from layout/nearable_demo.xml
            spinnerDropDown = (Spinner) findViewById(R.id.spinner1);  //For size available
            spinnerDropDown2 = (Spinner) findViewById(R.id.spinner2);//for colours available
            COO = (TextView) findViewById(R.id.textview2);//for country of origin
            SM = (TextView) findViewById(R.id.textview3); //for shoe model
            Price = (TextView) findViewById(R.id.textview4); //for price
}

private void updateCurrentNearable(List<Nearable> nearables) {
    for (Nearable nearable : nearables) {
        if (nearable.equals(currentNearable)) {
            currentNearable = nearable;
        }
    }
}
}

1 个答案:

答案 0 :(得分:0)

您正在identifier类的对象上调用Nearable 方法。这个课程中没有这样的方法:

http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/Nearable.html

但是,有identifier 属性,这是您需要使用的属性:

http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/Nearable.html#identifier

换句话说,这一行:

dbRow = stickerdb.getResult(currentNearable.identifier("065473d63cd9d687"));

......需要成为:

dbRow = stickerdb.getResult(currentNearable.identifier);