我有一个来自android studio项目的源代码,该源代码抛出11个我无法修复的错误。我完全按照youtube教程视频中的有关如何创建android聊天机器人的操作,输入的源代码也没有缺陷,但由于某种原因,它无法像教程视频那样工作。我试图将大多数错误标记为导入,但它也不起作用
error: cannot find symbol variable user_query_Layout
error: cannot find symbol method isMine()
error: cannot find symbol method isImage()
error: cannot find symbol variable user_query_Layout
error: cannot find symbol variable LayoutInflater
error: cannot find symbol class TextView
error: cannot find symbol variable bots_query_Layout
error: cannot find symbol class TextView
error: cannot find symbol variable Toast
package com.example.bot2000.Adapter;
import android.content.Context;
import android.widget.ArrayAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
import com.example.bot2000.Model.ChatMessage;
import com.example.bot2000.R;
public class ChatMessageAdapter extends ArrayAdapter<ChatMessage> {
private static final int MY_MESSAGE = 0;
private static final int BOT_MESSAGE = 1;
public ChatMessageAdapter(@NonNull Context context, List<ChatMessage> data) {
super(context, R.layout.user_query_Layout, data);
}
@Override
public int getItemViewType(int position) {
ChatMessage item = getItem(position);
if (item.isMine() && !item.isImage()) {
return MY_MESSAGE;
}
else {
return BOT_MESSAGE;
}
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
int viewType = getItemViewType(position);
if (viewType == MY_MESSAGE) {
convertView = LayoutInflater.from(getContext())
.inflate(R.layout.user_query_Layout,parent, false);
TextView textView = convertView.findViewById(R.id.text);
textView.setText(getItem(position).getContent());
}
else if (viewType == BOT_MESSAGE) {
convertView = LayoutInflater.from(getContext())
.inflate(R.layout.bots_query_Layout,parent, false);
TextView textView = convertView.findViewById(R.id.text);
textView.setText(getItem(position).getContent());
}
convertView.findViewById(R.id.chatMessageView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), "Clicked...", Toast.LENGTH_SHORT).show();
}
});
return convertView;
}
@Override
public int getViewTypeCount() {
return 2;
}
}