我正在编写一个android应用程序,它使用模糊推理来显示我的一项活动的最终结果。为此,我使用了jFuzzyLogic库,首先,我只想在我的应用程序中运行著名的提示器模糊问题,
但是当我用我的onCreate方法编写下面的代码并运行该应用程序时,应用程序会关闭并停止运行!
我想它不能加载FIS文件"tipper.fcl"请任何人帮忙
谢谢
下面是我的onCreate方法:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//context = MainActivity.this;
double out=0;
String error = "can't load fis" ;
my_textview = (TextView) findViewById(R.id.output_tv);
String fileName = "tipper.fcl";
FIS fis = FIS.load(fileName, true); // Load from 'FCL' file
if (fis == null) {
my_textview.setText(error);
}
fis.setVariable("service", 3);
fis.setVariable("food", 7);
fis.evaluate();
out = fis.getVariable("tip").getValue();
my_textview.setText(String.valueOf(out));
}发布于 2018-05-14 11:38:04
1.创建资产文件夹,并在其中放置tipper.fcl文件。
2.采用InputStream并传递资产文件夹路径
3.像这样
=getApplicationContext().getAssets().open("tipper.fcl");是InputStream
4.最后在InputStream方法中传递FIS.load对象如下
FIS = FIS.load(is,true);
https://stackoverflow.com/questions/44395845
复制相似问题