2017-03-02开始,记录的一些知识点。岁月长,三更漏。漫漫回廊,依稀人空瘦。借酒消愁入断肠,倚剑笑我,我独自寻殇。
<td class="col-xs-4" v-bind="item.CifName"></td> <td class="col-xs-4">{{item.CreateTime}}</td> <td class="col-xs-4">{{item.MobilePhone}}</td>
运行的效果如下:v-bind显示null,{{item.CreateTime}}显示空白。
// 设置剪贴板的内容 public void getCopy(View view) { ClipboardManager cmb = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText("hello world"); } // 得到剪贴板的内容 public void getPaste(View view) { ClipboardManager cmb = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE); String text = cmb.getText().toString(); }
详情可以参考博客: http://www.cnblogs.com/mengdd/p/3572316.html
@Override public void onBackPressed() { long currentTime = SystemClock.uptimeMillis(); if (currentTime - mbackPressedTime < (3 * 1000)) { finish(); } else { mbackPressedTime = currentTime; Toast.makeText(this, "确定要退出程序吗?", Toast.LENGTH_SHORT).show(); } }
<string name="huhx_lover">I love you, %s.</string>
java代码打印:
String name = "chenhui";
Log.i(TAG, "username: " + getString(R.string.huhx_lover, name));
<string name="html_text" formatted="false"> <![CDATA[ <font color=\‘#28b5f5\‘>Hello World</font> and <font color=\‘red\‘> I love you.</font> ]]> </string>
java的使用代码:
textView.setText(Html.fromHtml(getString(R.string.html_text)));
<uses-permission android:name = "android.permission.SET_WALLPAPER"/>
public void getMobileInfo(View view) { WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); try { wallpaperManager.setBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.goback)); } catch (IOException e) { e.printStackTrace(); } }
关于切换壁纸,可以参考博客:http://www.android100.org/html/201304/26/2349.html
public void getMobileInfo(View view) { TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); String deviceId = telephonyManager.getDeviceId(); // 865931020390837 String subscriberId = telephonyManager.getSubscriberId(); // null String model = Build.MODEL; // MI 4LTE int sdkInt = Build.VERSION.SDK_INT; // 23 DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int width = displayMetrics.widthPixels; // 1080 int height = displayMetrics.heightPixels; // 1920 }
关于手机的一些信息的获取,可以参考博客: http://blog.csdn.net/hytfly/article/details/8552483
public void getMobileInfo(View view) { DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); int width = metric.widthPixels; // 屏幕宽度(像素)1080 int height = metric.heightPixels; // 屏幕高度(像素)1920 float density = metric.density; // 屏幕密度 3.0 int densityDpi = metric.densityDpi; // 屏幕密度DPI 480 }
关于手机的屏幕信息的博客: http://www.cnblogs.com/renyuan/archive/2012/07/25/2607936.html
public void getMobileInfo(View view) { PackageManager pm = getPackageManager(); try { String packageName = getPackageName(); // com.example.huhx.basttest1 PackageInfo pinfo = pm.getPackageInfo(packageName, PackageManager.GET_CONFIGURATIONS); int versionCode = pinfo.versionCode; // 1 String versionName = pinfo.versionName; // 1.0 Log.i(TAG, "packageName: " + packageName + ", " + versionName + ", " + versionCode); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } }
et_text = (EditText) findViewById(R.id.et_text); String str = "hello world"; et_text.setText(str); et_text.setSelection(str.length());
注意setSelection里面的参数不能大于内容的长度。如果是 et_text.setSelection(str.length() + 1);则会抛出异常。
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="useCodeAsDefaultMessage" value="false"/> <property name="basenames"> <list> <value>META-INF/config/message/errorcode</value> </list> </property> <property name="defaultEncoding" value="UTF-8"/> </bean> </beans>
message={0} love {1}
public class MessageTest { public static void main(String[] args) { MessageSource source = new ClassPathXmlApplicationContext("META-INF/config/config.xml"); String message = source.getMessage("message", new Object[]{"huhx", "linux"}, null); System.out.println(message); // huhx love linux } }
具体的用法,可以参考博客:http://blog.csdn.net/qyf_5445/article/details/8124431
原文:http://www.cnblogs.com/huhx/p/basediary20161125.html