码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2018-02-27 11:32:35      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:nts   change   名称   creat   enabled   protected   builder   pre   appcompat   

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

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

标签:nts   change   名称   creat   enabled   protected   builder   pre   appcompat   

原文地址:https://www.cnblogs.com/xym4869/p/8477817.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!