0

我正在编写一个 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));

}
4

1 回答 1

1

1.创建资产文件夹并在其中放置tipper.fcl文件。
2.取InputStream并传递asset Folder Path
3.这样
的InputStream就是=getApplicationContext().getAssets().open("tipper.fcl");
4.finally 在 FIS.load 方法中传递 InputStream 对象,如
FIS fis = FIS.load(is, true);

于 2018-05-14T11:38:04.777 回答