本帖最后由 萧然3 于 2017-11-13 13:59 编辑
logcat打印错了是2错误的
代码:
[AppleScript] 纯文本查看 复制代码 public class MainActivity extends Activity {
protected static final int SUCCESS = 1;
protected static final int ERRER = 2;
private ListView lv;
private List<NewsBin> items;
final Handler myHandler = new Handler() {
public void handleMessage(android.os.Message msg) {System.out.println(msg.what);//打印 2
switch(msg.what) {
case SUCCESS :
lv.setAdapter(new newAdappter());
break;
case ERRER :
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Thread() {
public void run(){
try {
items = news.getNews("http://m.syxewy.com/news.xml");
Message msg = Message.obtain();
msg.what = SUCCESS;
myHandler.sendMessage(msg);
} catch (Exception e) {
Message msg = Message.obtain();
msg.what = ERRER;
myHandler.sendMessage(msg);
}
}
}.start();
|