-
03-21-2016, 07:00 AM #1Junior Member
- Ngày tham gia
- May 2014
- Bài viết
- 0
Nhờ các anh xem dùm code này sai chổ nào mà nó báo đỏ loét
package com.example.admin.docfilestuinternet;
import android.os.bundle;
import android.support.design.widget.floatingactionbutton ;
import android.support.design.widget.snackbar;
import android.support.v7.app.appcompatactivity;
import android.support.v7.widget.toolbar;
import android.view.view;
import android.view.menu;
import android.view.menuitem;
import java.io.ioexception;
import java.io.unsupportedencodingexception;
public class mainactivity extends appcompatactivity {
@override
protected void oncreate(bundle savedinstancestate) {
super.oncreate(savedinstancestate);
setcontentview(r.layout.activity_main);
toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar);
setsupportactionbar(toolbar);
floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab);
fab.setonclicklistener(new view.onclicklistener() {
@override
public void onclick(view view) {
snackbar.make(view, "replace with your own action", snackbar.length_long)
.setaction("action", null).show();
}
});
}
private string getxmlfromurl(string urlstring) {
string xml = null;
try {
// defaulthttpclient lấy toàn bộ dữ liệu trong http đổ vào 1 chuỗi string
defaulthttpclient httpclient = new defaulthttpclient();
httppost httppost = new httppost(urlstring);
httpresponse httpresponse = httpclient.execute(httppost);
httpentity httpentity = httpresponse.getentity();
xml = entityutils.tostring(httpentity, http.utf_8);
// set utf-8 cho ra chữ unikey
} catch (unsupportedencodingexception e) {
e.printstacktrace();
} catch (clientprotocolexception e) {
e.printstacktrace();
} catch (ioexception e) {
e.printstacktrace();
}
// return xml
return xml;
}
các hàm defaulthttpclient, httppost , httpresponse, httpentity báo lỗi đỏ lét - em không hiểu thiếu thư việc gì!
mong các anh hỗ trợ giúp, em mới tập tành học android!! thanks
-
03-22-2016, 07:00 AM #2Junior Member
- Ngày tham gia
- Dec 2014
- Bài viết
- 3
hi bạn .
đây là câu trả lời cho bạn
http://upques.com/questions/tai-sao-ham-httpclient-khong-import-duoc--56c702b358f8dc0d7c5d344e
-
Trứng rung điều khiển từ xa Vibrator Spark Of Love Sản phẩm trứng rung bluetooth có điều khiển từ xa này được thiết kế với tông màu Rose Gold viền kim loại qua. Kích thước 7,4cm x 3,5cm giúp trứng...
TOP 3 trùy rung không dây cực kích thích cho phụ nữ