一卷旌收千骑虏,万全身出百重围。这篇文章主要讲述大三小学期 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
【大三小学期 Android开发的一些经验】6.edittext提示为android:hint,edittext默认text为android:text
推荐阅读
- 教我徒弟Android开发入门
- Android Studio 第五十六期 - Android之系统设置选项的包名
- 65.dynamic mapping
- Appium自动化测试学习笔记 —— Appium原理
- call()与apply()用法
- Android学习之AutoCompleteTextView和MultiAutoCompleteTextView
- AndroidStudio Frameworks detected: Android framework is detected in the project Configure
- webpack4:compilation.mainTemplate.applyPluginsWaterfall is not a function 解决方法
- Mac命令行打开APP