Android AS代码警告 (个人笔记)

将 android:layout_marginLeft="10dp"  替换成 android:layout_marginStart="10dp"  能更好的支持从右到左的布局

android:gravity="center|left"

 代码警告解释 替换为  android:gravity="center|start"



Android AS代码警告 (个人笔记)_第1张图片

android: paddingLeft 提示 Redundant attribute paddingLeft; already defining paddingStart with targetSdkVersion 23  

优化方法及警告解释  android:paddingStart="10dp"   android:paddingEnd="0dp"

 TextView.setText 


int money=0;

 money_txt.setText(money+"元" );提示警告问题

Do not concatenate text displayed with setText. Use resource string with placeholders.

警告解释

Handler   提示 应该改成静态类 否则可能造成内存溢出

This Handler class should be static or leaks might occur (anonymous android.os.Handler)

 解决方法 

MyHandlerhandler =new MyHandler(this);

static class MyHandlerextends Handler {

    WeakReferencemActivity;

        MyHandler(Login activity) {

            mActivity =new WeakReference<>(activity);

            }

    @Override

    public void handleMessage(Message msg) {

                Login loginactivity =mActivity.get();

                String text = (String) msg.obj;

                switch (msg.what) {

                       case 0:

                        loginactivity.submit_login.setClickable(true);

                        break;

                }

    }

}


你可能感兴趣的:(Android AS代码警告 (个人笔记))