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
时间: 2024-10-07 11:01:59