程序ab的问题

时间:2014-03-27 15:54:07

标签: java

在eclipse中使用ab.jar时,我在尝试运行bot时遇到以下错误。 “找不到类'org.alicebot.ab.Bot',从方法中引用......”。正在导入聊天类,但无法导入bot类。

这是我的代码:

 import org.alicebot.ab.Bot;
 import org.alicebot.ab.Chat;

 import android.annotation.SuppressLint;
 import android.app.ActionBar.LayoutParams;
 import android.app.Activity;
 import android.os.Bundle;
 import android.view.View;
 import android.view.ViewTreeObserver;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.LinearLayout;
 import android.widget.ScrollView;
 import android.widget.TextView;

 public class MainActivity extends Activity {


 String usertext; String response;
 String botname="MAVIS";
 Bot mavis=new Bot(botname);
 Chat chat= new Chat(mavis);

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 // TODO Auto-generated method stub
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main); 
 final LinearLayout ll1 = (LinearLayout) findViewById(R.id.ll1);
 final LinearLayout ll2 = (LinearLayout) findViewById(R.id.ll2);
 final ScrollView scv = (ScrollView) findViewById(R.id.sv);
 final Button btn = (Button) findViewById(R.id.button1);
 final EditText medit = (EditText) findViewById(R.id.editText1);

 btn.setOnClickListener(new View.OnClickListener() {

 @SuppressLint("NewApi")
 @Override
 public void onClick(View v) { 

 TextView tvu=new TextView(v.getContext());
 TextView tvb=new TextView(v.getContext());

 TextView tvut=new TextView(v.getContext());
 TextView tvbt=new TextView(v.getContext());

 TextView tvdivider1=new TextView(v.getContext());
 TextView tvdivider2=new TextView(v.getContext());  

 final LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT,  LayoutParams.WRAP_CONTENT);

 tvu.setLayoutParams(lparams);
 tvb.setLayoutParams(lparams);

 tvut.setLayoutParams(lparams);
 tvbt.setLayoutParams(lparams);

 tvdivider1.setLayoutParams(lparams);
 tvdivider2.setLayoutParams(lparams);

 usertext = medit.getText().toString();
 if(usertext.trim().length() != 0){

 ll1.addView(tvu);
 ll1.addView(tvb);
 ll2.addView(tvut);
 ll2.addView(tvbt);
 ll1.addView(tvdivider1);
 ll2.addView(tvdivider2);

 response=chat.multisentenceRespond(usertext);

 tvu.setText("User");
 tvb.setText(botname);

 tvbt.setText(" : "+ response);
 tvut.setText(" : "+ usertext);
 medit.setText(" ");

 tvdivider1.setText("   ");
 tvdivider2.setText("   --------------------");
 }
  else{
   //do nothing
      }
  }
  });

scv.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {
            scv.post(new Runnable() {
                public void run() {
                    scv.fullScroll(View.FOCUS_DOWN);
                }
            });
        }
    });
   }

   }  

我导入了外部库并为其定义了类路径。我还在我的项目文件夹中复制了ab.jar,甚至为它定义了类路径。但似乎没有任何效果。我这样做是错误的还是有更多的库可供使用。有人解决了我的问题吗?

1 个答案:

答案 0 :(得分:0)

你的机器人名称在这里是MAVIS ..如果您从bots.zip更改文件夹名称,请更改它。或者只使用预定义的机器人名称(alice2等)。 Thankz