Android Xutils 프레임 워 크
xUitls 최저 호 환 안 드 로 이 드 2.2(api level 8)
DbUtils 모듈:
4.567917.바 인 딩 외 키 를 지원 하고 실 체 를 저장 할 때 외 키 관련 실 체 를 자동 으로 저장 하거나 업데이트 합 니 다
4.567917.체인 표현 조 회 를 지원 하고 더욱 직관 적 인 조회 의 미 를 지원 하 며 아래 의 소개 나 sample 중의 예 를 참고 합 니 다
ViewUtils 모듈:
HttpUtils 모듈:
GET,POST,PUT,MOVE,COPY,DELETE,HEAD 요청 을 지원 합 니 다
BitmapUtils 모듈:
네트워크 그림 과 로 컬 그림 을 불 러 오 는 것 을 지원 합 니 다
4.567917.메모리 관 리 는 lru 알고리즘 을 사용 하여 bitmap 메모 리 를 더욱 잘 관리 합 니 다
xUtils 빠 른 개발 프레임 워 크 를 사용 하려 면 다음 과 같은 권한 이 필요 합 니 다.
android:name="android.permission.INTERNET" /> android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
혼동 시 주의사항:
DbUtils 모듈 을 사용 하여 오래 지속 되 는 실체 클래스 를 혼동 하거나 모든 표 와 열 이름@Table(name="xxx"),@Id(column="xxx"),@Column(column="xxx"),@Foreign(column="xxx",foreign="xxx")을 주석 하지 마 십시오
DbUtils 사용법:
DbUtils db = DbUtils.create(this); User user = new User(); // User id , @ID user.setEmail("[email protected]"); user.setName("wyouflf"); db.save(user); // saveBindingId id ... // Parent entity = db.findById(Parent.class, parent.getId()); Parent entity = db.findFirst(entity);// entity List<Parent> list = db.findAll(entity);// entity Parent Parent = db.findFirst(Selector.from(Parent.class).where("name","=","test")); List<Parent> list = db.findAll(Selector.from(Parent.class) .where("id",",54) .and("age",">",30) .or("age",",20) .orderBy("id") .limit(10) .offset(0)); DbModel dbModel = db.findDbModelAll(Selector.from(Parent.class).select("name"));//select("name") name List<DbModel> dbModels = db.findDbModelAll(Selector.from(Parent.class).groupBy("name").select("name", "count(name)")); ...
ViewUtils 사용 방법
4.567917.완전 주해 방식 으로 UI 바 인 딩 과 이벤트 바 인 딩 을 할 수 있 습 니 다
@ViewInject(R.id.textView) TextView textView; // , id @OnClick(R.id.test_button) public void testButtonClick(View v) { ... } ... // ( onCreate ): @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewUtils.inject(this); ... textView.setText("some text..."); ... }
HttpUtils 사용 방법:
일반 get 방법
HttpUtils http = new HttpUtils(); http.send(HttpRequest.HttpMethod.GET, "http://www.lidroid.com", new RequestCallBack<String>(){ @Override public void onLoading(long total, long current) { testTextView.setText(current + "/" + total); } @Override public void onSuccess(String result) { textView.setText(result); } @Override public void onStart() { } @Override public void onFailure((HttpException error, String msg) { } });
HttpUtils 를 사용 하여 파일 을 업로드 하거나 서버 에 데 이 터 를 제출 합 니 다(post 방법)
RequestParams params = new RequestParams(); params.addHeader("name", "value"); params.addQueryStringParameter("name", "value"); // BodyParamsEntity, // UrlEncodedFormEntity("application/x-www-form-urlencoded")。 params.addBodyParameter("name", "value"); // MultipartEntity("multipart/form-data"), // "multipart/related",xUtils MultipartEntity subType "related"。 // params.setBodyEntity(httpEntity) HttpEntity( : // MultipartEntity,BodyParamsEntity,FileUploadEntity,InputStreamUploadEntity,StringEntity)。 params.addBodyParameter("file", new File("path")); ... HttpUtils http = new HttpUtils(); http.send(HttpRequest.HttpMethod.POST, "uploadUrl....", params, new RequestCallBack<String>() { @Override public void onStart() { testTextView.setText("conn..."); } @Override public void onLoading(long total, long current) { testTextView.setText(current + "/" + total); } @Override public void onSuccess(String result) { testTextView.setText("upload response:" + result.getPath()); } @Override public void onFailure(HttpException error, String msg) { testTextView.setText(error.getExceptionCode() + ":" + msg); } });
HttpUtils 로 파일 다운로드:
HttpUtils http = new HttpUtils(); HttpHandler handler = http.download("http://apache.dataguru.cn/httpcomponents/httpclient/source/httpcomponents-client-4.2.5-src.zip", "/sdcard/httpcomponents-client-4.2.5-src.zip", true, // , 。 true, // , 。 new RequestCallBack<File>() { @Override public void onStart() { testTextView.setText("conn..."); } @Override public void onLoading(long total, long current) { testTextView.setText(current + "/" + total); } @Override public void onSuccess(File result) { testTextView.setText("downloaded:" + result.getPath()); } @Override public void onFailure(HttpException error, String msg) { testTextView.setText(msg); } }); ... // stop() handler.stop(); ...
BitmapUtils 사용 방법
BitmapUtils.create(this).display(testImageView, "http://bbs.lidroid.com/static/image/common/logo.png"); //BitmapUtils.create(this).display(testImageView, "/sdcard/test.jpg"); // // ListView PauseOnScrollListener listView.setOnScrollListener(new PauseOnScrollListener(bitmapUtils, false, true)); listView.setOnScrollListener(new PauseOnScrollListener(bitmapUtils, false, true), customListener);
기타(**더 많은 예제 코드 는 sample 폴 더 의 코드**참조)
출력 로그 LogUtils
// TAG, : className[methodName, lineNumber] // allowD,allowE..., log。 LogUtils.d("wyouflf");
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Bitrise에서 배포 어플리케이션 설정 테스트하기이 글은 Bitrise 광고 달력의 23일째 글입니다. 자체 또는 당사 등에서 Bitrise 구축 서비스를 사용합니다. 그나저나 며칠 전 Bitrise User Group Meetup #3에서 아래 슬라이드를 발표했...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.