我正在开发一个使用 estimote 贴纸的鞋贴纸项目,但遇到了一些问题。我在我的项目中使用 android studio
我在 dbRow = Stickerdb.getResult(currentNearable.identifier("065473d63cd9d687"));
处出现错误它表示需要调用方法
错误日志: 错误:(96, 52) 错误:找不到符号方法标识符(字符串)
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;
}
}
}
}
最佳答案
您正在对 Nearable
类的对象调用标识符
方法。这个类中没有这样的方法:
http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/Nearable.html
但是,有一个标识符
属性,这就是您需要使用的:
http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/Nearable.html#identifier
换句话说,这一行:
dbRow = stickerdb.getResult(currentNearable.identifier("065473d63cd9d687"));
...需要成为:
dbRow = stickerdb.getResult(currentNearable.identifier);
关于java - 在NearablesDemoActivity.java中添加什么方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33338709/