android篇——如何做一个简单的安卓源码查看器

Mainactivity篇:

进口java.io.InputStream;进口java.net.HttpURLConnection;

进口java.net.MalformedURLException;进口java.net.URL。


进口android.os.Bundle;

进口handler;进口android.os.Looper;

进口android.os.Message;进口android.app.Activity;

进口android.view.Menu;进口android.view.View;

进口android.widget.EditText;进口android.widget.TextView;

进口android.widget.Toast;


公共类Mainactivity延伸活动{


protected 最后一个int REQUESTSUCESS=0;,//ctrl + shift + X Y

protected 最后一个int REQUESTNOTFOUND=1;

protected 最后一个int REQUESTEXCEPTION=2;

私人EditText et_path;

私人TextView tv_reuslt;


//在主线程中定义一个handler 

私人处理程序处理程序=new处理程序(){

//这个方法是在主线程里面执行的,

公共空handleMessage (android.os。消息味精){

//所以就可以在主线程里面更新界面了,

//[1]区分一下发送的是哪条消息,

开关(msg.what) {

案例REQUESTSUCESS:,,//代表请求成功

字符串内容=,(字符串)msg.obj;

tv_reuslt.setText(内容),

打破;

案例REQUESTNOTFOUND:,,//代表请求成功

Toast.makeText (getApplicationContext(),“请求资源不存在”,0),告诉();

打破;

案例REQUESTEXCEPTION:,,//代表请求成功

Toast.makeText (getApplicationContext(),“服务器忙请稍后....”1),告诉(),

打破;

默认值:

打破;

}

};

};


@Override

保护空白

,,xmlns:工具=" http://schemas.android.com/tools "

,,android: layout_width=" match_parent "

,,android: layout_height=" match_parent "

,,android:取向=按怪薄?/p>

,,工具:上下文="。MainActivity”在


,,EditText & lt;

,,,,android: id=癅 + id/et_path”

,,,,android: layout_width=" match_parent "

,,,,android: layout_height=" wrap_content "

,,,,android:提示="请输入查看网址”/祝辞


,,& lt;按钮

,,,,android: layout_width=" wrap_content "

,,,,android: layout_height=" wrap_content "

,,,,android: onClick="点击"

,,,,android:文本="查看“/祝辞


,,& lt; ScrollView

,,,,android: layout_width=" match_parent "

,,,,android: layout_height=" wrap_content "在


,,,,& lt; TextView

,,,,,,android: id=癅 + id/tv_result”

,,,,,,android: layout_width=" match_parent "

,,,,,,android: layout_height=" match_parent "

,,,,,,android:文本=" hagha "/祝辞

,,& lt;/ScrollView>


& lt;/LinearLayout>



最后最重要的是勿忘配置许可证

android篇——如何做一个简单的安卓源码查看器