1,调web浏览器 Uri myBlogUri = Uri.parse("http://xxxxx.com"); returnIt = new Intent(Intent.ACTION_VIEW, myBlogUri); 2,地图 Uri mapUri = Uri.parse("geo:38.899533,-77.036476"); returnIt = new Intent(Intent.ACTION_VIEW, mapUri); 3,调拨打电话界面 Uri telUri = Uri.parse("tel:100861"); returnIt = new Intent(Intent.ACTION_DIAL, telUri); 4,直接拨打电话 Uri callUri = Uri.parse("tel:100861"); returnIt = new Intent(Intent.ACTION_CALL, callUri); 5,卸载 Uri uninstallUri = Uri.fromParts("package", "xxx", null); returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri); 6,安装 Uri installUri = Uri.fromParts("package", "xxx", null); returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 7,播放 Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3"); returnIt = new Intent(Intent.ACTION_VIEW, playUri); 8,掉用发邮件 Uri emailUri = Uri.parse("mailto:[email protected]"); returnIt = new Intent(Intent.ACTION_SENDTO, emailUri); 9,发邮件 returnIt = new Intent(Intent.ACTION_SEND); String[] tos = { "[email protected]" }; String[] ccs = { "[email protected]" }; returnIt.putExtra(Intent.EXTRA_EMAIL, tos); returnIt.putExtra(Intent.EXTRA_CC, ccs); returnIt.putExtra(Intent.EXTRA_TEXT, "body"); returnIt.putExtra(Intent.EXTRA_SUBJECT, "subject"); returnIt.setType("message/rfc882"); Intent.createChooser(returnIt, "Choose Email Client"); 10,发短信 Uri smsUri = Uri.parse("tel:100861"); returnIt = new Intent(Intent.ACTION_VIEW, smsUri); returnIt.putExtra("sms_body", "yyyy"); returnIt.setType("vnd.android-dir/mms-sms"); 11,直接发邮件 Uri smsToUri = Uri.parse("smsto://100861"); returnIt = new Intent(Intent.ACTION_SENDTO, smsToUri); returnIt.putExtra("sms_body", "yyyy"); 12,发彩信 Uri mmsUri = Uri.parse("content://media/external/images/media/23"); returnIt = new Intent(Intent.ACTION_SEND); returnIt.putExtra("sms_body", "yyyy"); returnIt.putExtra(Intent.EXTRA_STREAM, mmsUri); returnIt.setType("image/png"); 最后一步: startActivity(returnIt) 如何把Button或者ImageButton的背景设为透明或者半透明? android:background=”@android:color/transparent” or android:background="@null" or 半透明<Button android:background="#e0000000"/> 透明<Button android:background="#00000000"/> 如何在TextView显示HTML? TextView tv=(TextView)findViewById(R.id.tv); Spanned text = Html.fromHtml("<a href=‘http://www.baidu.com‘>baidu</a>"); tv.setText(text); 如果html中有图片,请参考这篇文章: http://da-en.iteye.com/blog/712415 如何修改软键盘默认为数字输入? EditText editText = (EditText) findViewById(R.id.et); editText.setInputType(InputType.TYPE_CLASS_NUMBER); 13.如何阻止EditText自动弹出输入法? editText.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { //记住EditText的InputType现在是password int inType = editText.getInputType(); // backup the input type editText.setInputType(InputType.TYPE_NULL); // disable soft input editText.onTouchEvent(event); // call native handler editText.setInputType(inType); // restore input type editText.setSelection(editText.getText().length()); return true; } }); 14.如何自定义标题栏? //首先需要请求对FEATURE_CUSTOM_TITLE操作 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); view = new SnakeView(this); setContentView(view); //然后设置 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title); R.layout.title对应的布局文件: <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center" android:gravity="center" android:text="Snake" android:textColor="@color/red" /> </LinearLayout> 这里需要注意,最好不要修改背景色,否则会出现标题栏不会被充满的问题(会露马脚啦:)),如果确实需要修改背景色又不漏马脚,那么请看这篇文章: http://www.iteye.com/topic/760314 15.如何隐藏标题栏? 即:应用程序名称的那一栏 //注意:2行代码的先后顺序不能颠倒 requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); //同时使用隐藏状态栏可以使可视面积最大化! 或者也可以在Manifest文件中这样设置: <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
时间: 2024-11-08 07:09:53