【Android】2015.08.28 安卓官方文档学习:Day1 Count:1

-----------------------------------------------
Android Official Documents
Day1
Building your first app
-----------------------------------------------
Questions:
1. What are  the contents of view and view group?

2. Where is R.java?

3. Why Activity class is subclass of Context?

4. editText.getText() : return Editable! What is it? Why not String?

5. how to understand Intent?

6. ant adb  is what?



Points:
1. Install Command 
cd to android skd path, open avd :  tools/android avid
install app on device :  adb install app/build/outputs/
2. Layout_weight
<EditText
   
android:layout_weight="1"
   
android:layout_width="0dp"
    ... />
What is weight?
The weight value is a number that specifies the amount ofremaining space each view should consume, relative to the amount consumed by sibling views. This works kind of like the amount of ingredients in a drink recipe: "2 parts soda, 1 part syrup" means two-thirds of the drink is soda. For example, if you give one view a weight of 2 and another one a weight of 1, the sum is 3, so the first view fills 2/3 of the remaining space and the second view fills the rest. If you add a third view and give it a weight of 1, then the first view (with weight of 2) now gets 1/2 the remaining space, while the remaining two each get 1/4.
The default weight for all views is 0, so if you specify any weight value greater than 0 to only one view, then that view fills whatever space remains after all views are given the space they require.

Why set 0dp?
etting the width to zero improves layout performance because using  "wrap_content"  as the width requires the system to calculate a width that isultimately irrelevant because the weight value requires another width calculation to fill the remaining space.


-----------------------------------------------
Android Official Documents
Day1
Adding the action bar
-----------------------------------------------

Questions:
1. class:  menuinflater translate so confusing ,what is it for? 
This class is used to instantiate menu XML files into Menu objects.
我们知道,LayoutInflater是用来实例化整个布局文件,而 MenuInflater是用来实例化Menu目录下的Menu布局文件的。

  传统意义上的菜单定义需要Override Activity的onCreateOptionsMenu,然后在里面调用Menu.add把Menu的一个个item加进来,比较复杂。而通过使用MenuInflater可以把Menu的构造直接放在Menu布局文件中,真正实现模型(Model)与视图(View)的分离,程序也看着清爽多了。



Points:
1.getActionBar().setDisplayHomeAsUpEnabled(true);
Its function is to support back key intthe actionbar ,but it is default true in the recent android system.



Terms
1. inflate: 使充气 ,膨胀
inflate the menu: 增加菜单 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值