android如何判断是用户还机器代码

 更新时间:2016年9月20日 20:00  点击:1366
本文章介绍一段超张简单的关于android如何判断是用户还机器代码,有需要的朋友可参考。

我们写程序的时候可能需要判断用户到底使用的是模拟器还是真机,可以使用如下的代码

 代码如下 复制代码
private boolean isEmulator() {
    return (Build.MODEL.equals("sdk")) || (Build.MODEL.equals("google_sdk"));
}
本文章来介绍在android开发中,我们通过button按钮来动态改变字体大小、字体颜色、背景颜色代码,有需要了解的朋友可参考参考。

实现的逻辑:通过遍历View的方式,判断View是否是TextView、EditText和Button类型,如果是的话,就修改。

代码如下:
1、xml布局文件,文件名:test4.xml,内容如下:

 代码如下 复制代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   android:id="@+id/mainLayout">
    
     
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
         
        <EditText android:id="@+id/fontSize"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="30"
        android:hint="请输入数字"/>
         
        <Button android:id="@+id/ChangeSize"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="改变字体"/>    
         
    </LinearLayout>
     
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
         
        <EditText android:id="@+id/fontColor"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="#ffffff"
        android:hint="请输入字体颜色"/>
         
        <Button android:id="@+id/ChangeColor"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="改变字体颜色" />    
         
    </LinearLayout>
     
     
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
         
        <EditText android:id="@+id/bgColor"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="#ff0000"
        android:hint="请输入背景颜色"/>
         
        <Button android:id="@+id/ChangeBgColor"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="改变背景颜色"/>    
         
    </LinearLayout>
     
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
      
    
   <TextView android:id="@+id/TextView01"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="top"
                   android:gravity="top"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView02"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="bottom"
                   android:gravity="bottom"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView03"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="left"
                   android:gravity="left"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView04"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="right"
                   android:gravity="right"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView05"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="center_vertical"
                   android:gravity="center_vertical"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView06"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="fill_vertical"
                   android:gravity="fill_vertical"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView07"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="center_horizontal"
                   android:gravity="center_horizontal"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView08"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="fill_horizontal"
                   android:gravity="fill_horizontal"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>                                                                                                                                     
 
   <TextView android:id="@+id/TextView09"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="center"
                   android:gravity="center"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView10"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="fill"
                   android:gravity="fill"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView11"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="clip_vertical"
                   android:gravity="clip_vertical"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
                    
   <TextView android:id="@+id/TextView12"
                   android:layout_width="fill_parent"
                   android:layout_height="50dp"
                   android:text="clip_horizontal"
                   android:gravity="clip_horizontal"
                   android:textColor="#ffffff"
                   android:background="#00ff00"
                   android:layout_margin="2px"/>
    </LinearLayout>                                                                                               
</LinearLayout>

2、实现的代码文件:MainActivity.java,代码如下:

 代码如下 复制代码

package org.shuxiang.test;
 
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
public class MainActivity extends Activity{
         
        private LinearLayout mainLayout;
        private Button changeSize, changeColor, changeBgColor;
        private EditText fontSize, fontColor, bgColor;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.test4);
         
        mainLayout = (LinearLayout) findViewById(R.id.mainLayout);
        changeSize = (Button) findViewById(R.id.ChangeSize);
        fontSize = (EditText) findViewById(R.id.fontSize);
         
        changeSize.setOnClickListener(new OnClickListener()
        {
                        @Override
                        public void onClick(View v)
                        {
                                // TODO Auto-generated method stub
                                setFontSize(mainLayout, Float.parseFloat(fontSize.getText().toString()));
                        }                
        });
         
        changeColor = (Button) findViewById(R.id.ChangeColor);
        fontColor = (EditText) findViewById(R.id.fontColor);
         
        changeColor.setOnClickListener(new OnClickListener()
        {
                        @Override
                        public void onClick(View v)
                        {
                                // TODO Auto-generated method stub
                                int color = Integer.parseInt(fontColor.getText().toString().replace("#", ""), 16);
                                int red = (color & 0xff0000) >> 16; 
                            int green = (color & 0x00ff00) >> 8; 
                            int blue = (color & 0x0000ff); 
                             
                            setFontColor(mainLayout, Color.rgb(red, green, blue));                                
                        }                
        });
         
        changeBgColor = (Button) findViewById(R.id.ChangeBgColor);
        bgColor = (EditText) findViewById(R.id.bgColor);
         
        changeBgColor.setOnClickListener(new OnClickListener()
        {
                        @Override
                        public void onClick(View v)
                        {
                                // TODO Auto-generated method stub
                                int color = Integer.parseInt(bgColor.getText().toString().replace("#", ""), 16);
                                int red = (color & 0xff0000) >> 16; 
                            int green = (color & 0x00ff00) >> 8; 
                            int blue = (color & 0x0000ff);
                             
                                setBgColor(mainLayout, Color.rgb(red, green, blue));
                        }                
        });        
 
        
    }
     
    /**
     * 改变字体
     * @param v
     * @param fontSize
     */
    public void setFontSize(View v, float fontSizeValue)
    {
            if(v instanceof TextView)
                {
                        ((TextView) v).setTextSize(fontSizeValue);
                }
                else if(v instanceof EditText)
                {
                        ((EditText) v).setTextSize(fontSizeValue);
                }
                else if(v instanceof Button)
                {
                        ((Button) v).setTextSize(fontSizeValue);
                }
                else
                {
                        int vChildCount = ((ViewGroup) v).getChildCount();
                    for(int i=0; i<vChildCount; i++)
                    {
                            View v1 = ((ViewGroup) v).getChildAt(i);
                            setFontSize(v1, fontSizeValue);
                    }
                }        
    }
     
    /**
     * 改变字体颜色
     * @param v
     * @param fontSize
     */
    public void setFontColor(View v, int fontColorValue)
    {
            if(v instanceof TextView)
                {
                        ((TextView) v).setTextColor(fontColorValue);
                }
                else if(v instanceof EditText)
                {
                        ((EditText) v).setTextColor(fontColorValue);
                }
                else if(v instanceof Button)
                {
                        ((Button) v).setTextColor(fontColorValue);
                }
                else
                {
                        int vChildCount = ((ViewGroup) v).getChildCount();
                    for(int i=0; i<vChildCount; i++)
                    {
                            View v1 = ((ViewGroup) v).getChildAt(i);
                            setFontColor(v1, fontColorValue);
                    }
                }        
    }
     
    /**
     * 改变背景字体
     * @param v
     * @param fontSize
     */
    public void setBgColor(View v, int bgColorValue)
    {
            if(v instanceof TextView)
                {
                        ((TextView) v).setBackgroundColor(bgColorValue);
                }
                else if(v instanceof EditText)
                {
                        ((EditText) v).setBackgroundColor(bgColorValue);
                }
                else if(v instanceof Button)
                {
                        ((Button) v).setBackgroundColor(bgColorValue);
                }
                else
                {
                        int vChildCount = ((ViewGroup) v).getChildCount();
                    for(int i=0; i<vChildCount; i++)
                    {
                            View v1 = ((ViewGroup) v).getChildAt(i);
                            setBgColor(v1, bgColorValue);
                    }
                }        
    }    
 
}

本文章介绍一个入门型号的教程,关于android 如何判断当前设备是模拟器还是真机和设置当前的Activity的屏幕亮度实例有需要的朋友可参考。

/** 判断是否模拟器。如果返回TRUE,则当前是模拟器
     * @param context
     * @return
*/ 

 代码如下 复制代码

public static boolean isEmulator(Context context){ 
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); 
        String imei = tm.getDeviceId(); 
        if (imei == null || imei.equals("000000000000000")){ 
            return true; 
        } 
        return false; 
}

这个方法没大量测试过,应该是WORK的,一般真机都有IMEI的,不过也见过工程机的IMEI是000000000000000还是0。



设置当前的Activity的屏幕亮度,而不是设置系统的屏幕亮度,退出当前的Activity后恢复系统的亮度。 直接看代码好了

 代码如下 复制代码

WindowManager.LayoutParams lp = getWindow().getAttributes(); 

lp.screenBrightness = 0.5f; 
getWindow().setAttributes(lp); 

  screenBrightness的值范围是0到1。 注意不要设成0,屏幕会黑掉,完全看不到。

本文章来给大简单介绍关于android LinearLayout 布局实例效果,有需要了解的朋友可参考参考。

先明确几个概念的区别:
padding margin都是边距的含义,关键问题得明白是什么相对什么的边距.
padding是控件的内容相对控件的边缘的边距.
margin是控件边缘相对父控件的边距.

android:gravity 属性是对该view 内容的限定.比如一个button 上面的text. 你可以设置该text 在view的靠左,靠右等位置.该属性就干了这个.
android:layout_gravity是用来设置该view中的子view相对于父view的位置.比如一个button 在linearlayout里,你想把该button放在靠左,靠右等位置就可以在linearlayout中通过该属性设置.

 代码如下 复制代码

<?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="wrap_content" android:gravity="center_vertical">
 <ImageView android:id="@+id/ivLogo" android:layout_width="50dp"
  android:layout_height="50dp" android:src="@drawable/icon"
  android:paddingLeft="5dp" />
 <RelativeLayout android:id="@+id/rl_name"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:gravity="right"
  android:padding="10dp">
  <TextView android:id="@+id/tvApplicationName"
   android:layout_width="wrap_content" android:layout_height="wrap_content"
   android:textSize="16dp" />
 </RelativeLayout>
 <RelativeLayout android:id="@+id/rl_score"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:gravity="right"
  android:padding="10dp">
  <TextView android:id="@+id/tvRating" android:layout_width="wrap_content"
   android:layout_height="wrap_content" android:text="5.0" />
  <RatingBar android:id="@+id/ratingbar" android:layout_width="wrap_content"
   android:layout_height="wrap_content" android:numStars="5"
   style="?android:attr/ratingBarStyleSmall" android:layout_below="@id/tvRating" />
 </RelativeLayout>
</LinearLayout>

例2

 代码如下 复制代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="red"
android:gravity="center_horizontal"
android:background="#aa0000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>

<TextView
android:text="green"
android:gravity="center_horizontal"
android:background="#00aa00"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>

<TextView
android:text="blue"
android:gravity="center_horizontal"
android:background="#0000aa"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>

<TextView
android:text="yellow"
android:gravity="center_horizontal"
android:background="#aaaa00"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>

</LinearLayout>

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2">

<TextView
android:text="row one"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>

<TextView
android:text="row two"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>

<TextView
android:text="row three"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>

<TextView
android:text="row four"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>

</LinearLayout>

</LinearLayout>

给linearlayout设置边框 .

1.首先在res目录下新建一个xml文件,类型选择drawable,将自动生一个一个drawable文件(我用的sdk是android 4.1),并生成一个xml文件,在其中写入以下代码:

 代码如下 复制代码

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <solid android:color="#FFFFFF" />

    <stroke
        android:width="0.01dp"
        android:color="#FFFFFF" />

    <padding
        android:bottom="1dp"
        android:left="0.5dp"
        android:right="0.5dp"
        android:top="0dp" />
</shape>

2.在要设置边框的控件xml命令里加入:android:background=“@drawable/boder”

本文章来给大这简单介绍关于Android动态改变对 onCreateDialog话框值,Android Dev-Guide 推荐重写Activity.onCreateDialog()方法来创建Dialog,这样Dialog就归属于这个Activity了。

使用方法是这样的,Activity.showDialog()激发Activity.onCreateDialog()创建Dialog,然后显示之,便于多个Dialog的统一管理。

注意,以后再用Activity.showDialog()显示同一个Dialog时,则不会调用Activity.onCreateDialog(),

而是调用Activity.onPrepareDialog(),使用上一次显示Dialog时的状态。即

第一次:showDialog() -> onCreatedialog()
以后: showDialog() -> onPrepareDialog()

在用oncreatedialog回调创建dialogd时候,系统会缓存dialog,下次直接就显示上次显示的内容。

当一个Dialog第一次被调用的时候,Android系统会调用你应该实例化Dialog的Activity的onCreateDialog方法,

这个方法会启动你从showDialog(int)方法里面传递的那个ID参数所定义的Dialog,当你创建成功后,在方法的最后回返回这个Dialog。

     在Dialog显示之前,Android也会调用回调函数onPripareDialog(int,Dialog),当你想在这个Dialog每次打开的时候一些属性得到改变,你可以定义这个方法,

这个方法会在每次Dialog打开的时候被调用,onCreateDialog()只会在Dialog第一次打开的时候被调用,如果你没有定义onPrepareDialog(),

每次返回的Dialog都是和第一次显示的Dialog一样,这个方法需要传递一个ID和在onCreateDialog()方法中创建的Dialog。

      最好的定义onCreateDialog()和onPrepareDialog()中使用switch对传入的id进行下判断,每一个case对应着要启动的Dialog的ID


* 动态改变对话框值
* 关键点:onPrepareDialog方法 里面调用 removeDialog(id);
* 对话框调用执行顺序 showDialog() -> onCreateDialog() -> onPrepareDialog() -> removeDialog()

 代码如下 复制代码
 
  @Override
     public void onPrepareDialog(int id, Dialog dialog) {
         switch (id) {
         case (DIALOG_SORT_MAILS):
             removeDialog(id);  //移出掉onCreateDialog()创建的Dialog
             break;
         }
}

上面讲到了Dialog,下面我来介绍android Dialog用法


一个Dialog一直被创建及作为Activity的一部分显示的时候,一般情况下,你应该使用回调方法onCreateDialog(int)创建Dialog,当你使用这个方法的时候,Android系统会自动的管理每一个Dialog的状态,并有效的控制着每个Dialog,同样的,每个Dialog也会继承Activity中的某些特性。就像当一个Dialog显示的时候,按下菜单键显示Activity定义的选项菜单或者使用音量键调整音视频音量的大小,当你想显示一个Dialog的时候,调用showDialog(int)方法,传递的参数是唯一能标识你想显示的对话框的整数。
当一个Dialog第一次被调用的时候,Android系统会调用你应该实例化Dialog的Activity的onCreateDialog方法,这个方法会启动你从showDialog(int)方法里面传递的那个ID参数所定义的Dialog,当你创建成功后,在方法的最后回返回这个Dialog。

在Dialog显示之前,Android也会调用回调函数onPripareDialog(int,Dialog),当你想在这个Dialog每次打开的时候一些属性得到改变,你可以定义这个方法,这个方法会在每次Dialog打开的时候被调用,onCreateDialog()只会在Dialog第一次打开的时候被调用,如果你没有定义onPrepareDialog(),每次返回的Dialog都是和第一次显示的Dialog一样,这个方法需要传递一个ID和在onCreateDialog()方法中创建的Dialog。


当你准备关闭对话框时,你可以通过对这个对话框调用dismiss()来消除它。如果需要,你还可以从这个Activity中调用dismissDialog(int id) 方法,这实际上将为你对这个对话框调用dismiss() 方法。 如果你想使用onCreateDialog(int id) 方法来管理你对话框的状态(就如同在前面的章节讨论的那样),然后每次你的对话框消除的时候,这个对话框对象的状态将由该Activity保留。如果你决定不再需要这个对象或者清除该状态是重要的,那么你应该调用removeDialog(int id)。这将删除任何
内部对象引用而且如果这个对话框正在显示,它将被消除。


最好的定义onCreateDialog()和onPrepareDialog()中使用switch对传入的id进行下判断,每一个case对应着要启动的Dialog的ID,像下面这个例子一样:

 代码如下 复制代码

protected Dialog onCreateDialog(int id)
{
switch(id)
{
case 1:
{
ProgressDialog checkUpdateIng = new ProgressDialog(CallPlayer.this);
checkUpdateIng.setTitle("正在下载");
checkUpdateIng.setMessage("请稍候...");
checkUpdateIng.setProgressStyle(ProgressDialog.STYLE_SPINNER);
return checkUpdateIng;
}
case 2:
{
Dialog dialog = new AlertDialog.Builder(CallPlayer.this).setTitle("系统更新").setMessage("发现新版本,请更新!") // 设置内容
.setPositiveButton("确定", // 设置确定按钮
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog,int which)
{
downloadBar = new ProgressDialog(CallPlayer.this);
downloadBar.setTitle("正在下载");
downloadBar.setMessage("请稍候...");
downloadBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
downloadUpdateFile();
}
 
}).setNegativeButton("取消",new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
// 点击"取消"按钮之后退出程序
init();
callPlayer();
}
}).create();// 创建
return dialog;
}
default:
{
return null;
}
}
}

[!--infotagslink--]

相关文章

  • php 获取用户IP与IE信息程序

    php 获取用户IP与IE信息程序 function onlineip() { global $_SERVER; if(getenv('HTTP_CLIENT_IP')) { $onlineip = getenv('HTTP_CLIENT_IP');...2016-11-25
  • Android子控件超出父控件的范围显示出来方法

    下面我们来看一篇关于Android子控件超出父控件的范围显示出来方法,希望这篇文章能够帮助到各位朋友,有碰到此问题的朋友可以进来看看哦。 <RelativeLayout xmlns:an...2016-10-02
  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • php 调用goolge地图代码

    <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
  • JS基于Mootools实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • JS+CSS实现分类动态选择及移动功能效果代码

    本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
  • JS实现自定义简单网页软键盘效果代码

    本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
  • php 取除连续空格与换行代码

    php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
  • php简单用户登陆程序代码

    php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1...2016-11-25
  • Android开发中findViewById()函数用法与简化

    findViewById方法在android开发中是获取页面控件的值了,有没有发现我们一个页面控件多了会反复研究写findViewById呢,下面我们一起来看它的简化方法。 Android中Fin...2016-09-20
  • PHP实现清除wordpress里恶意代码

    公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
  • Android模拟器上模拟来电和短信配置

    如果我们的项目需要做来电及短信的功能,那么我们就得在Android模拟器开发这些功能,本来就来告诉我们如何在Android模拟器上模拟来电及来短信的功能。 在Android模拟...2016-09-20
  • 夜神android模拟器设置代理的方法

    夜神android模拟器如何设置代理呢?对于这个问题其实操作起来是非常的简单,下面小编来为各位详细介绍夜神android模拟器设置代理的方法,希望例子能够帮助到各位。 app...2016-09-20
  • JS实现双击屏幕滚动效果代码

    本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
  • android自定义动态设置Button样式【很常用】

    为了增强android应用的用户体验,我们可以在一些Button按钮上自定义动态的设置一些样式,比如交互时改变字体、颜色、背景图等。 今天来看一个通过重写Button来动态实...2016-09-20
  • js识别uc浏览器的代码

    其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
  • Android WebView加载html5页面实例教程

    如果我们要在Android应用APP中加载html5页面,我们可以使用WebView,本文我们分享两个WebView加载html5页面实例应用。 实例一:WebView加载html5实现炫酷引导页面大多...2016-09-20
  • JS日期加减,日期运算代码

    一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
  • 深入理解Android中View和ViewGroup

    深入理解Android中View和ViewGroup从组成架构上看,似乎ViewGroup在View之上,View需要继承ViewGroup,但实际上不是这样的。View是基类,ViewGroup是它的子类。本教程我们深...2016-09-20
  • PHP开发微信支付的代码分享

    微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31