How to development a Android App
Before you begin, Let’s talk about Android lifecycle first . Learn about Android’s four major components,And to be familiar with Android development tool -Android Studio.
Activity
1 | Activity1->Activity2: onCreate()——>onStart()——>onResume() |
when you push a new Activity or back Activity, it’s due to the stack to manage the Activity status, but how to push a new Activity?
1 | Intent intent = new Intent(ReorderFour.this, ReorderTwo.class); |
Activity Extented
after we know the android activity, i want tall about fragment.
Perhaps you have seen the most app interfaces is like this. YEs ,it’s Tabbar UI Interface.
效果图
so, what about the fragment ?
- tabbar interface is a activity contains one or more fragments.
- fragments lifecycle is rely one activity.
what did I do to make layout the UITabarActivity?
app gradle 配置
项目结构
Tabbar Activity
Layout 布局
界面Fragment配置
ok,after you see my screenshots, you can know , i use the ViewpagerIndicator to make a tabbar Activity . it can manager fragments. you can easy to change every fragment you need.
app gradle instroduce
1. use the fastjson to make json parse.
2. use the butterknife replace the frequent findViewById.
3. use the ViewPagerIndicator to achieve a tabbarActivity interface.
4. use the android-smart-image-view to make the image cache.
5. use the android-async-http to make http request.
6. use the recycleView-v7 replace the android system listView.
7. use the bga-refreshlayout to make the pull refresh cool header.
8. finally, use cn.bingoogolapple:bga-adapter to make the recycleView cell Item can right move delete, long press event ,ItemChildClickListener ,and so on . all in all, bga-adapter is perfect !
For your convenience, i encapsulated a tableview like iOS UITableView , you can use the group style or plain style decide by youself; you can find it in the package com.lvj.bookoneday->widget.view
1 | //定义表格的数据源接口 |
1 | //定义表格的事件委托源 |
- I create two java interface : TableViewDelete, TableViewDataSoucre. that you can easy
implements there’s methods . - when you use the activity or fragment need tableView layout , you can easy and fast
layout ,and implements TableViewDelegate, TableViewDatasource.
for examples
Talk about Http request
you know, when your app ask a request, may be have two Design Patterns . it named “block”(anonymous inner classes) ,”delegate”(delegate is named by iOS. on java, it’s interface or ask “OOP” thoughts).
My HttpRequest Design
there is a abstract class named BaseDataService. if you have a new request . you just extend BaseDataService and @Override three methods. “getAPIRequestMethodName
, setRequestParams,parseResponse”. look these screenshots. And on your Activity or Fragments , you just implemets RequestCallBackDelegate , and you can use your son of BaseDataService to make some request.
父类
子类继承父类
界面用子类请求实现
For more info about the tableView how to work, you can find my open source on my Github Android-TableView,welcome make you suggestion. if you like this project, on my github, I hope you can click on the star in the upper right corner to give me more encouragement. thank you!