Android 学习记录-UDACITY项目0反馈

UDACITY 刚刚登陆中国,前一个月纳米学位免费试用,好奇的我为了检测自己的学习成果,从最简单的组件组合项目做起,没报多大希望地提交了自己做的东西,没想到第二天就给我了回复,效率真是高。。也从反馈中看到了许多缺陷,需要注意的地方。。

效果图

存在的问题

1 . 布局我采用LinearLayout 典型的线性布局

回复建议:

I can’t click on the other buttons when I rotated the device. To fix

that, you can change to a ScrollView or you can also create the

landscape layout.

可以用ScrollView 包裹着 LinearLayout

2 . 字体大小我用的dp,

回复建议:

When setting text sizes, you should normally use sp, or”scale-independent pixels”. This is like the dp unit, but it is alsoscaled by the user’s font size preference.

It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and the user’s preference.

sp可以更好的适应屏幕,具体参见stackoverflow单位区别

3 . 我的属性值都是直接给出

   <Button  android:layout_width="200dp" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="Build It Bigger" android:textAllCaps="true" android:background="#F08C35" android:onClick="click_build"/>
    <Button  android:layout_width="200dp" android:background="#F08C35" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="Xyz Reader" android:textAllCaps="true" android:onClick="click_reader"/>

回复建议:

It is a good practice to define dimensions value in dimens.xml file, colors value in color.xml file, string in string.xml file …

Try to have this practice for your next project

将一些配置值保存在string,color,dimens 里面便于修改和维护。

4 . 提示信息

 Toast.makeText(getApplicationContext(),
                "This button will launch my Score app",
                Toast.LENGTH_SHORT).show();

回复建议:

Please put the text “This button will launch…” into string.xml file and use getString to access this ressource
Besides you can change or translate your text easily later.

提示信息保存到string文件,重用性比较高。

5 . 功能写成函数

 public void click_library(View view){
        Toast.makeText(getApplicationContext(),
                "This button will launch my Library app",
                Toast.LENGTH_SHORT).show();
    }

回复建议:

You can create a helper function to avoid repeating Toast.makeText…..:

void DisplayText(String s){
Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show(); }

And call this:

public void clic_score(View view) {
DisplayText(R.string.scores_toast); }

6 . 点击事件

public void click_build(View view){
        Toast.makeText(getApplicationContext(),
                "This button will launch my Build app",
                Toast.LENGTH_SHORT).show();
    }

    public void click_myOwn(View view){
        Toast.makeText(getApplicationContext(),
                "This button will launch my my own app",
                Toast.LENGTH_SHORT).show();
    }

回复建议:

Here other lazy way: using butterknife library - http://jakewharton.github.io/butterknife/

@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
}

 @OnClick({ R.id.button,
   R.id.button2,
   R.id.button3,
   R.id.button4,
   R.id.button5,
   R.id.button6})

public void showToast(Button button) {
Toast.makeText(this, String.format(getString(R.string.button_message), button.getText()),
Toast.LENGTH_SHORT).show();
}

以上就是存在的问题,虽然应用很简单,但是问题和需要注意和改进的地方还是有的。

你可能感兴趣的:(android,布局,udacity-纳米,问题反馈)