• 大三小学期 Android开发的一些经验


    1.同一个TextView几种颜色的设置:

    build=(TextView)findViewById(R.id.building);
    SpannableStringBuilder style = new SpannableStringBuilder("建筑物名称*");
    style.setSpan(new ForegroundColorSpan(Color.BLACK), 0, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    style.setSpan(new ForegroundColorSpan(Color.RED), 5, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    build.setText(style);
    显示出来就是:建筑物名称*
     
    2.判断输入不为空:
    //建筑物名称不能为空
    building.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if(TextUtils.isEmpty(building.getText())||TextUtils.isEmpty(floor.getText())
                    ||TextUtils.isEmpty(telephone.getText())||TextUtils.isEmpty(description.getText()))
            {
                upload.setEnabled(false);
                Toast.makeText(Feedback.this,"请完成反馈信息的填写",Toast.LENGTH_LONG).show();
            }
            else
            {
                upload.setEnabled(true);
            }
    
        }
    
        @Override
        public void afterTextChanged(Editable s) {
    
        }
    });
    3.两个界面之间传递值,值为double类型:
    发送方:
    Intent intent = new Intent(selectPoint.this,Feedback.class);
    intent.putExtra("latitude",latitude);
    intent.putExtra("longtitude",longtitude);
    startActivity(intent);

    接收方:

    Intent intent=getIntent();
    final double longtitude = intent.getDoubleExtra("longtitude",0);
    final double latitude = intent.getDoubleExtra("latitude",0);

    4.设置app开头动态效果(转自:http://blog.csdn.net/nmsoftklb/article/details/12943483)

    public class Welcome extends AppCompatActivity {
        private ImageView welcome;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_welcome);
    
            welcome = (ImageView) this.findViewById(R.id.welcome);
            AlphaAnimation anima = new AlphaAnimation(0.3f, 1.0f);
            anima.setDuration(3000);// 设置动画显示时间
            welcome.startAnimation(anima);
            anima.setAnimationListener(new AnimationImpl());
        }
    
        private class AnimationImpl implements Animation.AnimationListener {
    
            @Override
            public void onAnimationStart(Animation animation) {
                welcome.setBackgroundResource(R.drawable.welcome);
            }
    
            @Override
            public void onAnimationEnd(Animation animation) {
                skip(); // 动画结束后跳转到别的页面
            }
    
            @Override
            public void onAnimationRepeat(Animation animation) {
    
            }
    
        }
    
        private void skip() {
            startActivity(new Intent(this, Feedback.class));
            finish();
        }
    }

    5.去掉界面上面的蓝色默认的头

    public class Award extends AppCompatActivity
    改成
    public class Award extends Activity

    6.edittext提示为android:hint,edittext默认text为android:text

  • 相关阅读:
    Codeforces 903F Clear the Matrix
    Codeforces 899D Shovel Sale
    Codeforces 898E Squares and not squares
    Codeforces 899B Months and Years
    Codeforces 854B Maxim Buys an Apartment:贪心
    BZOJ 1198 [HNOI2006]军机调度:dfs
    BZOJ 1196 [HNOI2006]公路修建问题:二分 + 贪心生成树check(类似kruskal)
    BZOJ 1193 [HNOI2006]马步距离:大范围贪心 小范围暴搜
    BZOJ 1192 [HNOI2006]鬼谷子的钱袋:二进制 砝码称重问题
    BZOJ 1191 [HNOI2006]超级英雄Hero:二分图匹配 匈牙利算法
  • 原文地址:https://www.cnblogs.com/xym4869/p/8477817.html
Copyright © 2020-2023  润新知