android小点子
2014-01-04 13:08
429 查看
1.分享功能简单实现。
2、发送错误报告
3、点赞动画
很多地方我们会用到,点赞功能,点了按钮之后,会有一个"+1" 或者“-1” 飘上来。
这里值提供了简单实现。其实这样的实例网上一大片。
4.android Fragment
转载:http://blog.csdn.net/jiayi_fly/article/details/9823087
shareBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent localIntent = new Intent("android.intent.action.SEND"); localIntent.setType("text/plain"); String str = "这个是我的分享内容你看看。"; localIntent.putExtra("android.intent.extra.TEXT", str + "#aaa#"); localIntent.setFlags(268435456);// MainActivity.this.startActivity(Intent.createChooser( localIntent, "测试文字")); } }); 很多人使用startActivity时候,会碰到如下的异常: Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? 都知道,Context中有一个startActivity方法,Activity继承自Context,重载了startActivity方法。如果使用Activity的startActivity方法,不会有任何限制,而如果使用Context的startActivity方法的话,就需要开启一个新的task,遇到上面那个异常的,都是因为使用了Context的startActivity方法。解决办法是,加一个flag。 Java代码 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 这样就可以再新的task里面启动这个Activity了。
2、发送错误报告
Intent localIntent = new Intent("android.intent.action.SEND"); localIntent.setType("message/rfc822"); String[] arrayOfString = new String[1]; arrayOfString[0] = "aaa@163.com"; localIntent.putExtra("android.intent.extra.EMAIL", arrayOfString); localIntent.putExtra("android.intent.extra.SUBJECT", "你的程序崩溃了,我要发送错误报告!"); localIntent.putExtra("android.intent.extra.TEXT", "草,"); MainActivity.this.startActivity(Intent.createChooser(localIntent, "发送错误报告"));
3、点赞动画
很多地方我们会用到,点赞功能,点了按钮之后,会有一个"+1" 或者“-1” 飘上来。
这里值提供了简单实现。其实这样的实例网上一大片。
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 动画移动效果,并且透明度逐渐增大一点,最后控件gone掉就行了 --> <translate android:duration="350" android:fromXDelta="0" android:fromYDelta="0" android:toXDelta="0" android:toYDelta="-30" /> <alpha android:duration="300" android:fromAlpha="1.0" android:toAlpha="0.3" /> </set>
thumbBtn = (Button) findViewById(R.id.thumbupbtn); thumbtext = (TextView) findViewById(R.id.thumbuptextview); thumbBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Animation animation = AnimationUtils.loadAnimation( MainActivity.this, R.anim.thanslateanimation); thumbtext.setVisibility(View.VISIBLE); thumbtext.setAnimation(animation); new Handler().postDelayed(new Runnable() { // 延迟一下在消失,主线程中,所以可以直接操作ui @Override public void run() { thumbtext.setVisibility(View.GONE); } }, 200); ((Button) v).setTextColor(Color.RED); } });
4.android Fragment
转载:http://blog.csdn.net/jiayi_fly/article/details/9823087
相关文章推荐
- 谷歌1月6日召开Android发布会 谷歌手机露端倪
- Android UI开发专题(二) 之绘图基础
- Android应用程式编译成系统程序简介
- 转:iPhone Android Web开发(概要)
- kinect 无法在我的android开发板上显示的分析
- Android Alarm会唤醒系统,但不会唤醒屏幕!
- 黑马程序员Java培训和Android培训_网络编程
- Android 网络应用重点———使用HttpGet 下载apk文件并安装
- Android安全:GingerMaster--第一个在Android2.3上利用root权限攻击的恶意软件20110818
- 【Based Android】Android Sensor感应器介绍(一)重力感应加速度获取
- Android Apps 对话框汇总
- module and macro in Android.mk
- Android 获取图片之固定大小的缩略图(一)
- android 屏幕设置相关
- java4android 学习随记
- Android禁止横竖屏和解决切换屏幕时重启Activity的方法
- Android SAX读取XML文件
- android资源适配
- (转)通过wifi调试android程序
- Android APK多个ICON入口