大三小学期 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

转载于:https://www.cnblogs.com/xym4869/p/8477817.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值