1、复制,粘贴
clip = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
clip.setText("copy"); // 复制
clip.getText(); // 粘贴
2、调用浏览器
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.cnblogs.com");
intent.setData(content_url);
//调用指定浏览器—UC
intent.setClassName("com.uc.browser", "com.uc.browser.ActivityUpdate");
startActivity(intent);
参考文章:http://android.tgbus.com/Android/tutorial/201108/366290.shtml
3、根据包名,去软件市场查找
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:com.acp.main"));
startActivity(intent);
4、Toast一直显示
final Toast toast = Toast.makeText(context,"toast", Toast.LENGTH_LONG);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated methodstub
while (flag) {
toast.show();
}
}
}, 10);
5、自定义Dialog
final Dialog mInfoDlg = new Dialog(context,R.style.dialog);// R.style.dialog – 去掉dialog的最上面title部分
LayoutInflater factory = LayoutInflater.from(context);
View nCurrView = factory.inflate(R.layout.mydialog, null);
nCurrView.setBackgroundResource(R.drawable.bgline);
LinearLayout nParentLayout = (LinearLayout)nCurrView.findViewById(R.id.iparents);
nParentLayout.setBackgroundResource(R.drawable.titlebgline);
mInfoDlg.setContentView(nCurrView);
Button nBt1 = (Button)nCurrView.findViewById(R.id.button1);
nBt1.setText("返回");
nBt1.setTypeface(Typeface.create(Typeface.SERIF, Typeface.BOLD));
nBt1.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated methodstub
mInfoDlg.dismiss();
}
});
mInfoDlg.show();
R.style.dialog:
<?xml version="1.0"encoding="utf-8"?>
<resources>
<style name="dialog"parent="@android:style/Theme.Dialog">
<itemname="android:windowNoTitle">true</item>
</style>
</resources>
R.drawable.titlebgline:
<?xml version="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android">
<gradientandroid:startColor="#ff9911" android:endColor="#FF9911"/>
<strokeandroid:width="1dp" android:color="@color/inputTxt" />
<cornersandroid:radius="5dp" />
</shape>
分享到:
相关推荐
自己整理的自定义控件方法,看了你就会做自定义Dialog和Toast了,没有多余代码,很简洁。背景、按钮都能自定义
自定义对话框LoadingDialog和Toast,可以添加Gif动画的Dialog,喜欢的自行下载!
android利用布局文件自定义Dialog、Toast
自定义Toast,设置Toast显示位置,自定义Toast的复杂布局 博客地址:http://blog.csdn.net/xy_nyle/article/details/20137953
主要为大家详细介绍了android自定义Toast设定显示时间,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
主要介绍了Android编程经典代码集锦,包括Android的复制,粘贴,浏览器调用,Toast显示,自定义Dialog等实现技巧,非常简单实用,需要的朋友可以参考下
和对话框不同的是,Toast并不是以独占方式显示的,它并不会抢夺用户的焦点,在弹出Toast的时候,依然可以对之前的界面进行操作,我们在“”一文中介绍了纯文本的Toast的使用,我们完全可以自定义Toast的显示内容和...
Android和iOS平台通用的自定义Toast UI组件 USAGE INSTALL npm install react-native-mix-toast IMPORT import Toast, { Duration, Position } from 'react-native-mix-toast'; EXAMPLE Toast.show('This is Toast',...
Android:实现Toast自定义样式(包括:自定义位置、带图片等)、自定义显示时长(包括可用系统时长、可自定义)
一个简单的自定义Toast资源,您可以根据自己的需要更改我的代码即可实现您想要的效果(主要是更改xml文件的布局),这是androidstudio的项目,但是不妨碍在eclipse中使用,可以直接在eclipse中新建android项目,然后将...
小程序自定义toast: 实现自定义 图标 及 显示文字,显示时间也可以设置 默认1s 自动隐藏
android 自定义toast,toast自定义显示时间,toast自定义显示样式
微信小程序Toast自定义组件
Android 源码演示5种toast显示效果,一共是以下几种演示:默认的Toast显示、自定义位置的Toast显示、带图片的Toast显示、完全自定义的Toast显示、长时间的Toast显示,Android 自定义5种toast显示效果。有的Toast效果...
AutoMessageDialog 自定义toast提示封装
自定义toast提示,可设置,做了封装
react-native-simple-toast, 简单的Toast React react-native-simple-toast对安卓和iOS的本机Toast组件进行反应。 它让iOS拥有与安卓相同的toast性能。 使用 scalessec/toast iOS ;安装你可以使用 rnpm插件轻松安装...
自定义Toast,解决系统Toast存在的问题
自定义Dialog实现自定义Toast.