Java textview中的Android logcat

Java textview中的Android logcat,java,android,android-studio,irc,Java,Android,Android Studio,Irc,我是android编程新手。我试图创建一个IRC机器人。我用过皮尔伯特图书馆。我的应用程序可以连接到服务器,但我不知道如何在android的文本视图中显示聊天输出。你能帮助我吗? Pircbot在Android Logcat中打印,有没有办法在文本视图中打印Logcat?多谢各位 这是我的起点_bot.java: import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.AppComp

我是android编程新手。我试图创建一个IRC机器人。我用过皮尔伯特图书馆。我的应用程序可以连接到服务器,但我不知道如何在android的文本视图中显示聊天输出。你能帮助我吗? Pircbot在Android Logcat中打印,有没有办法在文本视图中打印Logcat?多谢各位

这是我的起点_bot.java:

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

public class starting_bot extends MainActivity {
private irc_connection mAuthTask = null;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAuthTask = new irc_connection();
    mAuthTask.execute((Void) null);
    setContentView(R.layout.started_bot);

}


public class irc_connection  extends AsyncTask<Void, Void, Boolean> {
    @Override
    protected void onPreExecute(){
    }

    @Override
    protected void onProgressUpdate(Void[] values) {

    };

    @Override
    protected Boolean doInBackground(Void... params) {

        //ESEGUIRE OPERAZIONI IN BACKGROUND
        BotClass bot = new BotClass("nickname123");
        try {
            bot.setVerbose(true);
            bot.connect("irc server");
            //bot.sendMessage("nickserv","IDENTIFY <your password>" );
            bot.joinChannel("#ircchannel");
            Log.d("BOT:", "CONNESSO!");

        } catch (Exception e) {
            e.printStackTrace();
        }

        return true;


    }

    @Override
    protected void onPostExecute(final Boolean success) {

    }

    @Override
    protected void onCancelled() {
        mAuthTask = null;
    }
}
导入android.os.AsyncTask;
导入android.os.Bundle;
导入android.support.v7.app.AppActivity;
导入android.util.Log;
公共类启动\u bot扩展main活动{
专用irc_连接MAUTHSTASK=null;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
mAuthTask=新的irc_连接();
mAuthTask.execute((Void)null);
setContentView(R.layout.started\u bot);
}
公共类irc_连接扩展异步任务{
@凌驾
受保护的void onPreExecute(){
}
@凌驾
受保护的void onProgressUpdate(void[]值){
};
@凌驾
受保护的布尔doInBackground(Void…params){
//背景中的ESEGUIRE OPERAZIONI
BotClass bot=新的BotClass(“昵称123”);
试一试{
bot.setVerbose(true);
bot.connect(“irc服务器”);
//bot.sendMessage(“nickserv”、“IDENTIFY”);
bot.joinChannel(“ircchannel”);
Log.d(“BOT:,“CONNESSO!”);
}捕获(例外e){
e、 printStackTrace();
}
返回true;
}
@凌驾
受保护的void onPostExecute(最终布尔值成功){
}
@凌驾
受保护的void onCancelled(){
mAuthTask=null;
}
}
这是我的输出页面:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<View
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/output_java"/>
</LinearLayout>


两个问题:首先,要将任何内容打印到TextView,需要使用findViewById方法获取屏幕上TextView的句柄。其次,使用AsynTask在另一个线程中处理内容,这很好,但无法从另一个线程中更新TextView的文本,所有UI操作都需要执行UI线程是应用程序运行的主线程,为了避免它,您需要从doInBackground方法中调用updateProgress,updateProgress方法在UI线程上运行,您需要将数据从do in background方法发送到updateProgress方法,并从updateProgress方法更新textview非常感谢你的回答。但是我不能理解如何将数据从irc连接传递到textview。你能举个例子吗?非常感谢你的时间