月度归档:2019年03月

Android Expediton – ListView (Simple)

The most common and hardest widget

• First,creat in layout layer
    <ListView
    android:id="@+id/list_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    </ListView>
    ○ match_parent denote fill all the space in the layout
    ○ wrap_content denote the smallest area which can contain the content

• The data can not deliver to ListView directly, we need adapter, the best adapter is ArrayAdapter.
    ○ It use genericity(泛型) to assign(指定) the data which need to be delivered,then we deliver the data in the constructor(构造函数)
    ○ In the case, the data we used are all strings, so we set the genericity as String
    ○ Then, we should deliver current context(当前上下文), the id in subitem layout(子项布局的ID), the data need to be adapted(要适配的数据)
        § Tips: we use the android.R.layout.simple_list_item_1 as subitem layout ID, it's a bulit-in layout file in Android, there is only one TextView which can simplily show a piece of character
• CASE:
//------以下为一个最简单的(使用字符串数组)的ListView------
private String[] data = {
    "Apple","Banana","Orange","Watermelon","Pear","Grape","Pineapple","Strawberry","Cherry","Mango",
    "Apple","Banana","Orange","Watermelon","Pear","Grape","Pineapple","Strawberry","Cherry","Mango"
};


    @Override
protectedvoidonCreate(BundlesavedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ArrayAdapter<String>adapter=newArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, data);
    ListView listView = (ListView)findViewById(R.id.list_view);
    listView.setAdapter(adapter);
    }
}

OOAD Chapter3 I

• Stage
    ○ stage = (static)properties + (dynamic)value,usually
• Behavior 
    ○ denote obeject acts + reacts
    ○ denote as outway visiable activity
    ○ 1&#x20e3;&#xfe0f; Operation
        § Modifier
        § Selector
        § Iterator
        ---
        § Constructor
        § Destructer
    ○ 2&#x20e3;&#xfe0f; Roles and Responsibilities
        § Responsibilities = express one purpuse of an object(对象的一种目标) + it's place in the system(对象在系统中的位置)
        § Role:dynamic + mutually exclusive
• Identify
    ○ ~: The unique identity(neccesary the name) of each object is preserved over the lifetime of the object, even when it's state is changed.
    ○ 包括变量名和指针名
• The relationship of objects
    ○ Links
        § The pysical or conceptual connection(物理或概念上的联系) of two objects
        § A link denote the specifc association(具体的关系)
        § Usually unidrectional(单箭头),sometimes bidirectional(双箭头)
        § In a link, one object can act as these roles:
            □ Controller
            □ Server
            □ Proxy
        § 1&#x20e3;&#xfe0f; Visibility
            □ The two endpoints in a link can see each other
        § 2&#x20e3;&#xfe0f; Sychronization
            □ Whenever an object passes a message to anthor across a link, the two objects are said to be synchronized
            □ Sequatial
                ® Passive object linked to a active object at a time
            □ Guarded
                ® With the multiple threads control, active clients must collaborate(协作) to achive mutual exclusion(互斥)
            □ Concurrent
                ® With the multiple threads control, the supplier(服务提供者) guarantees() mutal exclusion

    ○ Aggregation

Denote a whole/part relationship(->整体/部分层次结构)

新的征程

我们的征程在这里开始,新的阶段,我该做哪些呢?
1. 专业课(课后即整理,课前必预复习!)
2. 雅思(每天安排固定的时间)
3. 网络安全学习&比赛(必须做,且做笔记整理📒)
4. 跑步健身(抽出完整的时间去健身房跑步)
5. 产品&项目能力(宝宝的产品书、专栏、Live、书)
6. 实习准备
7. 节约开支

每天要做的事情(规定时间,到达即停止🤚,强制执行):
1. 认真复习30个单词,20′
2. 写一篇博客文章,整理今日学习的内容,并安排明日计划,30’(每晚11:00-11:30)
3. 每天的话,20′
4. 跑步锻炼,60’(20’来回,40’锻炼)
5. 雅思准备,60’(每晚11:30 – 12:30)