首先要了解一点的是关于接口的基础知识: 

接口不能直接实例化
但是接口派生出来的抽象类可以实例化
所有派生出来的抽象类都可以强制转换成接口的实例

第三条我解释一下:比如,IList <Class> IList11 =new List <Class>(); 也就是接口派生出来的抽象类可以转换为接口的实例,这也是常说的里氏替换原则(子类对象可以代替父类对象,但其父类对象不能代替子类对象)

首先,List<T>是一个类,IList<T>是一个接口。接口和类的区别是本质的,类是负责功能的实现,而接口则是负责功能的定义。所以它们的区别本质上也就是类和接口的区别。

具体来说,IList 泛型接口是 ICollection 泛型接口的子代,并且是所有泛型列表的基接口。它仅仅是所有泛型类型的接口,并没有太多方法可以方便实用,如果仅仅是作为集合数据的承载体,那么使用IList<T>完全可以胜任。但是更多的时候,我们要对集合数据进行处理,从中筛选数据或者排序。这个时候IList<T>就爱莫能助了。

1、当你只想使用接口的方法时,ILis<>这种方式比较好.他不获取实现这个接口的类的其他方法和字段,有效的节省空间.

2、IList <>是个接口,定义了一些操作方法这些方法要你自己去实现

List <>是泛型类,它已经实现了IList <>定义的那些方法

IList <Class1> IList11 =new List <Class1>(); //这里是第三条规则的体现,实现低耦合,毕竟接口属最底层吧。IList1对象可以指向任意一个IList接口的实现

List <Class1> List11 =new List <Class1>(); 

这两行代码,从操作上来看,实际上都是创建了一个List<Class1>对象的实例,也就是说,他们的操作没有区别。

只是用于保存这个操作的返回值变量类型不一样而已。

那么,我们可以这么理解,这两行代码的目的不一样。

List <Class1> List11 =new List <Class1>();

是想创建一个List<Class1>,而且需要使用到List<T>的功能,进行相关操作。



IList <Class1> IList11 =new List <Class1>();

只是想创建一个基于接口IList<Class1>的对象的实例,只是这个接口是由List<T>实现的。所以它只是希望使用到IList<T>接口规定的功能而已。

再举一个例子,比如你要实现一个集合类,但是你认为添加的时候要做一下判断,不能重复,你可以这样做:

//方法1:

public class MyCollection1 : List<MyItem>

{

public new void Add(MyItem item)

{

if (this.Contains(item)) return;

base.Add(item);

}

}

//方法2:

public class MyCollection2 : IList<MyItem>

{

private List<MyItem> innerList = new List<MyItem>();

public void Add(MyItem item)

{

if (this.Contains(item)) return;

base.Add(item);

}

//实现n多的方法后,附带的,有个Add方法,实现即可,实现方法略

}

如果是从List继承而来,那我如果这样写,就能跳过检查了。但是不会调用你写的Add方法,而是调用List的Add方法。

MyCollection1 mc1 = new MyCollection1();

.....

System.Collection.IList listData = mc1;

listData.Add(listData[0]);

这样就不会执行你写的检查代码。但如果用下面方法,则会执行你写的Add方法:

MyCollection2 mc2 = new MyCollection2();

.....

System.Collection.IList listData = mc2;

listData.Add(listData[0]);

总之,正如那些高手说的:

接口实现低耦合...有利于系统的维护与重构...优化系统流程...

鼓励使用接口

这样可以实现功能和具体实现的分离

实现接口分离的原则

不是看实际需要用的

 另外在提供一个datatable转list<>的代码:

public IList<T> GetList<T>(DataTable table)
{
IList<T> list = new List<T>(); //里氏替换原则
T t = default(T);
PropertyInfo[] propertypes = null;
string tempName = string.Empty;
foreach (DataRow row in table.Rows)
{
 t = Activator.CreateInstance<T>(); ////创建指定类型的实例

propertypes = t.GetType().GetProperties(); //得到类的属性
foreach (PropertyInfo pro in propertypes)
{
tempName = pro.Name;
if (table.Columns.Contains(tempName.ToUpper()))
{
object value = row[tempName];
if (value is System.DBNull)
{
value = "";
}
pro.SetValue(t, value, null);
}
}
list.Add(t);
}
return list;

 其中   T t = default(T); //就是返回T的默认值。比如说T的类型是int类型的,那么这个default(T)的值就是0的;如果是string类型的话,这个返回值就是“”空字符串的。

 

posted @ 2011-12-27 20:55 子午 阅读(36) 评论(0) 编辑
eoe上有源码,点击一个自定义图片按钮控件,弹出自定义的一个dialog..内含输入框可登陆.
自定的图片按钮:ConnectButton.java
对话框:RenrenDialog.java
 
传值
Bundle bundle=new Bundle();bundle.putString("store", "数据来自Activity1");Intent mIntent=new Intent();
mIntent.putExtras(bundle);
获取
Bundle extras=getIntent().getExtras();
if(extras!=null){data=extras.getString("store");}
 
Dialog
//根据不同事件弹出不同的窗口
//showDialog(dialog)时调用这里
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG1: return buildDialog1(ActivityMain.this); case DIALOG2: return buildDialog2(ActivityMain.this); case DIALOG3: return buildDialog3(ActivityMain.this); case DIALOG4: return buildDialog4(ActivityMain.this); } return null; }
protected void onPrepareDialog(int id, Dialog dialog){ if(id==DIALOG1){ setTitle("测试"); }
//这里很奇怪,好像是窗口打开时运行的东西,判断某个为dialog1时改变标题(嗯,)
} Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { public void onClick(View v) { showDialog(DIALOG1); } }); Button buttons2 = (Button) findViewById(R.id.buttons2); buttons2.setOnClickListener(new OnClickListener() { public void onClick(View v) { showDialog(DIALOG2); } }); //。。其他button private Dialog buildDialog1(Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setIcon(R.drawable.alert_dialog_icon); builder.setTitle(R.string.alert_dialog_two_buttons_title); builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setTitle("点击了对话框上的确定按钮"); } }); builder.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setTitle("点击了对话框上的取消按钮"); } }); return builder.create(); }//弹出窗口信息

private Dialog buildDialog3(Context context) {
  LayoutInflater inflater = LayoutInflater.from(this);
  final View textEntryView = inflater.inflate(//在dialog内放入实例化的view,定义所需的内容,如登录信息等
    R.layout.alert_dialog_text_entry, null);
  AlertDialog.Builder builder = new AlertDialog.Builder(context);
  builder.setIcon(R.drawable.alert_dialog_icon);
  builder.setTitle(R.string.alert_dialog_text_entry);
  builder.setView(textEntryView);
  builder.setPositiveButton(R.string.alert_dialog_ok,
    new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int whichButton) {
      setTitle("点击了对话框上的确定按钮");
     }
    });
  builder.setNegativeButton(R.string.alert_dialog_cancel,
    new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int whichButton) {
      setTitle("点击了对话框上的取消按钮");
     }
    });
  return builder.create();
 }

 private Dialog buildDialog4(Context context) {
  ProgressDialog dialog = new ProgressDialog(context);//Loading 之前都是alertDialog,这里是ProgressDialog
  dialog.setTitle("正在下载歌曲");
  dialog.setMessage("请稍候……");
  return  dialog;
 }

 
待续
posted @ 2011-04-18 22:26 子午 阅读(400) 评论(0) 编辑
所谓自定义控件(或称组件)也就是编写自己的控件类型,而非Android中提供的标准的控件,如TextView,CheckBox等等.不过自定义的控件一般也都是从标准控件继承来的,或者是多种控件组合,或者是对标准控件的属性进行改变而得到的自己满意的控件.

    自定义控件可能会有很多种方法,这里只介绍我要介绍的方法.

 

    在这种方法中,大概的步骤是这样的

    1.我们的自定义控件和其他的控件一样,应该写成一个类,而这个类的属性是是有自己来决定的.

    2.我们要在res/values目录下建立一个attrs.xml的文件,并在此文件中增加对控件的属性的定义.

    3.使用AttributeSet来完成控件类的构造函数,并在构造函数中将自定义控件类中变量与attrs.xml中的属性连接起来.

    4.在自定义控件类中使用这些已经连接的属性变量.

    5.将自定义的控件类定义到布局用的xml文件中去.

    6.在界面中生成此自定义控件类对象,并加以使用.

 

    好了,按照上述的方法,我们来看看http://blog.csdn.net/Android_Tutor/archive/2010/04/20/5508615.aspx

    博客中的实例代码,按步骤加以解释:

    //---------------------------------------------------------------------------------

    1. 定义自己的控件类:--------------------------------------------代码1.

    package com.android.tutor;  
    import android.content.Context;  
    import android.content.res.TypedArray;  
    import android.graphics.Canvas;  
    import android.graphics.Color;  
    import android.graphics.Paint;  
    import android.graphics.Rect;  
    import android.graphics.Paint.Style;  
    import android.util.AttributeSet;  
    import android.view.View;  

 
    public class MyView extends View
    
        private Paint mPaint;  
        private Context mContext;  
        private static final String mString = "Welcome to Mr Wei's blog";  
      
        public MyView(Context context)
        
            super(context);  
            mPaint = new Paint();  
        

 
        public MyView(Context context,AttributeSet attrs)  
        
            super(context,attrs);  
            mPaint = new Paint();  
          
            TypedArray a = context.obtainStyledAttributes(attrs,R.styleable.MyView);             
            int textColor = a.getColor(R.styleable.MyView_textColor,0XFFFFFFFF);  
            float textSize = a.getDimension(R.styleable.MyView_textSize, 36);  
          
            mPaint.setTextSize(textSize);  
            mPaint.setColor(textColor);  
          
            a.recycle();  
        }

   
        @Override
        protected void onDraw(Canvas canvas)

        
            // TODO Auto-generated method stub  
            super.onDraw(canvas);  
            //设置填充  
            mPaint.setStyle(Style.FILL);  
          
            //画一个矩形,前俩个是矩形左上角坐标,后面俩个是右下角坐标  
            canvas.drawRect(new Rect(10, 10, 100, 100), mPaint);  
          
            mPaint.setColor(Color.BLUE);  
            //绘制文字  
            canvas.drawText(mString, 10, 110, mPaint);  
        }
  
   

    代码1定义了一个自定义控件,名字为MyView,是从View类继承而来,也就是说它本身就是一种View,只是在View基础上加工而成了我们自己的自定义控件MyView.在此类种黄色的两行变量是我们新的属性变量.

 

    //---------------------------------------------------------------------------------

    2. 在res/values目录下建立一个attrs.xml的文件,并在此文件中增加对控件的属性的定义--代码2:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <declare-styleable name="MyView">
            <attr name="textColor" format="color" />
            <attr name="textSize" format="dimension" />
        </declare-styleable>
    </resources>

    在<resources>标签下使用<declare-styleable name="MyView">标签来告诉框架它包含的属性就是自定义控件MyView中的属性.黄色的两其实就对应了代码1中黄色的变量.

 

    //---------------------------------------------------------------------------------

    3.使用AttributeSet来完成控件类的构造函数,并在构造函数中将自定义控件类中变量与attrs.xml中的属性连接起来.

    我们再看一下代码1中的蓝色代码,其中使用AttributeSet来重载构造函数.在此函数中将类中的属性变量与代码二中定义的属性联系起来.

    //---------------------------------------------------------------------------------

    4.在自定义控件类中使用这些已经连接的属性变量.

    我们看一下代码1中的黄色部分,就是对我们新定义的属性的使用.

 

    //---------------------------------------------------------------------------------

    5.将自定义的控件类定义到布局用的xml文件中去.-----代码3:

    我们再看看布局的xml文件代码:

    <?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"  
        <TextView android:layout_width="fill_parent"   
            android:layout_height="wrap_content"   
            android:text="@string/hello" />  

        <com.android.tutor.MyView  android:layout_width="fill_parent"   
            android:layout_height="fill_parent" test:textSize="20px" test:textColor="#fff" />  
    </LinearLayout>
    其中红色部分在布局中引用了我们MyView控件.

 

    //---------------------------------------------------------------------------------

    6.在界面中生成此自定义控件类对象,并加以使用.--------代码4.

 

    //---------------------------------------------------------------------------------

posted @ 2011-04-13 22:21 子午 阅读(4365) 评论(1) 编辑

manifest

<application .. android:name="KoubeiApp">

KoubeiApp.java应该是应用程序获取客户端一些通用信息,跟.net,global类似

static
{
fileName
= "config.properties";
sp
= null;
DEVICE_MODEL
= Build.MODEL;
StringBuilder localStringBuilder1
= new StringBuilder().append("android_");
String str1
= Build.VERSION.SDK;
CLIENT_OS
= str1;
CLIENT_VERSION
= "1.3";
CLIENT_ID
= "00000000000000";
CLIENT_POS_X
= "";
CLIENT_POS_Y
= "";
CLIENT_LOCAL_CITYNAME
= "鍖椾含";
CLIENT_LOCAL_CITYID
= "99";
CLIENT_SOURCE
= "koubei";
CLIENT_CITY_NAME
= null;
CLIENT_CITY_ID
= null;
CLIENT_SCREEN_SIZE
= "320*480";
StringBuilder localStringBuilder2
= new StringBuilder();
String str2
= Build.MODEL;
StringBuilder localStringBuilder3
= localStringBuilder2.append(str2);
String str3
= Build.VERSION.RELEASE;

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

放在onCreate后,setControlView之前,全屏(隐藏上方电量等属性)

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);设置屏幕竖排,横排或其他(枚举);

关于闪屏(就是首页停留几秒然后跳转,像html的setTimeout和setInternal)

Message msg = new Message(); msg.what = STOPSPLASH; splashHandler.sendMessageDelayed(msg, SPLASHTIME);

这个网上有好几种方式,目前研究不深,搞不清哪种比较好,http://www.cnblogs.com/royenhome/archive/2010/05/05/1727971.html?login=1他这里像是线程暂停,按下Menu键的话,直接跳过闪屏进入主界面;若按 下Back键的话,则直接退出主程序。还不错!我准备用这种方式

asynctask异步加载数据(有几种方法,关键要能用,找了这个)

public class Main extends Activity {

private LayoutInflater m_flater = null;
private LinearLayout mFlash;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.flash);
mFlash
= (LinearLayout) findViewById(R.id.mFlash);
mFlash.startAnimation(AnimationUtils
.loadAnimation(
this, R.anim.fadeout));
m_flater
= getLayoutInflater();
LoadMainTask task
= new LoadMainTask(this);
task.execute(
"");

}

public View LoadMainView(LayoutInflater flater) {
View view
= flater.inflate(R.layout.main, null);
Button btnOk
= (Button) view.findViewById(R.id.BtnOk);
btnOk.setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
finish();
}
});
return view;
}

private class LoadMainTask extends AsyncTask<Object, Object, View> {
public LoadMainTask(Context context) {
}

protected View doInBackground(Object... params) {
View view
= null;
view
= LoadMainView(m_flater);
// 为了测试加了延时,大家可以在这一块加载资源,数据等
try {
Thread.sleep(
3000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
return view;
}

// 执行完毕
protected void onPostExecute(View view) {
setContentView(view);
}
}

}

退出时自动弹出框提示是否要退出~

View Code
1 public boolean onKeyDown(int keyCode, KeyEvent event) {
2 // TODO Auto-generated method stub
3  
4 if(keyCode == KeyEvent.KEYCODE_BACK ){
5 AlertDialog.Builder builder=new AlertDialog.Builder(this);
6 builder.setTitle("提示");
7 builder.setMessage("确定要退出程序?");
8 builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
9
10 @Override
11 public void onClick(DialogInterface dialog, int which) {
12 // TODO Auto-generated method stub
13   dialog.dismiss();
14 finish();
15 }
16 });
17 builder.setNeutralButton("取消", new DialogInterface.OnClickListener() {
18
19 @Override
20 public void onClick(DialogInterface dialog, int which) {
21 // TODO Auto-generated method stub
22 dialog.dismiss();
23 }
24 });
25 builder.show();
26 return true;
27 }else{
28
29 return super.onKeyDown(keyCode, event);
30 }
31 }
posted @ 2011-04-07 12:40 子午 阅读(158) 评论(0) 编辑

Android开发平台中,可通过TelephonyManager 获取本机号码。

 

TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
txtPhoneNumber.setText(phoneMgr.getLine1Number()); //txtPhoneNumber是一个EditText 用于显示手机号

注:

根据Android的安全机制,在使用TelephonyManager时,必须在AndroidManifest.xml中添加<uses-permission android:name="READ_PHONE_STATE" /> 否则无法获得系统的许可。


手机型号 Build.MODEL

String MODEL The end-user-visible name for the end product.

sdk版本 Build.VERSION.SDK

String SDK This constant is deprecated. Use SDK_INT to easily get this as an integer.

及frimware版本号(系统版本号) Build.VERSION.RELEASE

String RELEASE The user-visible version string.

 

private void loadPhoneStatus()
{
TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
txtPhoneModel.setText(Build.MODEL); //手机型号
txtPhoneNumber.setText(phoneMgr.getLine1Number());//本机电话号码
txtSdkVersion.setText(Build.VERSION.SDK);//SDK版本号
txtOsVersion.setText(Build.VERSION.RELEASE);//Firmware/OS 版本号
}

事实上,Build能向我们提供包括 硬件厂商,硬件编号,序列号等很多信息 调用方法也都同上,很简单。

String BOARD The name of the underlying board, like "goldfish".
String BOOTLOADER The system bootloader version number.
String BRAND The brand (e.g., carrier) the software is customized for, if any.
String CPU_ABI The name of the instruction set (CPU type + ABI convention) of native code.
String CPU_ABI2 The name of the second instruction set (CPU type + ABI convention) of native code.
String DEVICE The name of the industrial design.
String DISPLAY A build ID string meant for displaying to the user
String FINGERPRINT A string that uniquely identifies this build.
String HARDWARE The name of the hardware (from the kernel command line or /proc).
String HOST
String ID Either a changelist number, or a label like "M4-rc20".
String MANUFACTURER The manufacturer of the product/hardware.
String MODEL The end-user-visible name for the end product.
String PRODUCT The name of the overall product.
String RADIO The radio firmware version number.
String SERIAL A hardware serial number, if available.
String TAGS Comma-separated tags describing the build, like "unsigned,debug".
long TIME
String TYPE The type of build, like "user" or "eng".
String UNKNOWN Value used for when a build property is unknown.
String USER

最近在做韩国一家公司的Android平台软件开发,我的手机号是韩国的啦。所以看到010打头的号码,别太惊讶..

 

转:http://www.cnblogs.com/mainroadlee/archive/2011/01/11/Android_Network_State_Checking_And_Setting.html

posted @ 2011-04-07 10:37 子午 阅读(435) 评论(0) 编辑

getJSON与aspx

准备工作

·Customer类

 

public class Customer
{
public int Unid { get; set; }
public string CustomerName { get; set; }
public string Memo { get; set; }
public string Other { get; set; }
}

 

(一)ashx

 

Customer customer = new Customer
{ Unid=1,CustomerName="宋江",Memo="天魁星",Other="黑三郎"};

string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(customer);

context.Response.Write(strJson);

 

function GetCustomer_Ashx() {
$.getJSON(
"webdata/Json_1.ashx",
function(data) {
var tt = "";
$.each(data, function(k, v) {
tt += k + ":" + v + "<br/>";
})

$("#divmessage").html(tt);
});
}

·通过getJSON向ashx请求数据。返回的数据为JSON对象。

(二)ashx文件,但返回的是实体集合

 

Customer customer = new Customer
{ Unid=1,CustomerName="宋江",Memo="天魁星",Other="黑三郎"};

Customer customer2 = new Customer
{ Unid = 2, CustomerName = "吴用", Memo = "天机星", Other = "智多星" };

List<Customer> _list = new List<Customer>();
_list.Add(customer);
_list.Add(customer2);

string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(_list);
context.Response.Write(strJson);

 

 

 

function GetCustomerList() {
$.getJSON(
"webdata/Json_1.ashx",
function(data) {
var tt = "";
$.each(data, function(k, v) {
$.each(v,function(kk, vv) {
tt += kk + ":" + vv + "<br/>";
});
});
$("#divmessage").html(tt);
});
}

具体可以参看:http://www.cnblogs.com/jams742003/archive/2009/12/25/1632276.html

(三)请求aspx文件

·cs文件

 

protected void Page_Load(object sender, EventArgs e)
{
Customer customer = new Customer
{ Unid = 1, CustomerName = "宋江", Memo = "天魁星", Other = "黑三郎" };

string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(customer);

Response.Write(strJson);
}

 

 

·Aspx文件

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json_1.aspx.cs"
Inherits="webdata_Json_1" %>

前台文件只保留Page声明,其它全部删除。

 

·js文件

 

function GetCustomer_Aspx() {
$.getJSON(
"webdata/Json_1.aspx",
function(data) {
var tt = "";
$.each(data, function(k, v) {
tt += k + ":" + v + "<br/>";
})
$("#divmessage").html(tt);
});
}

这个部分与请求ashx文件时相同。

请求实体集合时,与ashx时相同,这里不做重复。

(四)请求文本文件

文本文件提供json字符串,由$.getJSON得到json对象。

·文本文件

{Unid:1,CustomerName:"宋江",Memo:"天魁星",Other:"黑三郎"}

文本文件提供json串,对于json的组成格式,请参见其它文档。对于这一实体json,会被忽略空行与空格。

 

function GetCustomer_txt() {
$.getJSON(
"webdata/Json_1.txt",
function(data) {
var tt = "";
$.each(data, function(k, v) {
tt += k + ":" + v + "<br/>";
})
$("#divmessage").html(tt);
});
}

解析的方法与其它的相同。

 

对于多行的如下:

文本:

[

{Unid:1,CustomerName:"宋江",Memo:"天魁星",Other:"黑三郎"},

{Unid:2,CustomerName:"吴用",Memo:"天机星",Other:"智多星"}

]

 

解析:

 

function GetCustomer_TxtList() {
$.getJSON(
"webdata/Json_1.txt",
function(data) {
var tt = "";
$.each(data, function(k, v) {
$.each(v, function(kk, vv) {
tt += kk + ":" + vv + "<br/>";
});
});
$("#divmessage").html(tt);
});
}

与其它的相同。

(五)带参数ajax请求

以ashx为例子,按客户id来请求客户。

·Ashx文件

 

if(context.Request["iUnid"]==null)
return;

context.Response.ContentType = "text/plain";

Customer customer = new Customer
{ Unid = 1, CustomerName = "宋江", Memo = "天魁星", Other = "黑三郎" };

Customer customer2 = new Customer
{ Unid = 2, CustomerName = "吴用", Memo = "天机星", Other = "智多星" };

List<Customer> _list = new List<Customer>();
_list.Add(customer);
_list.Add(customer2);


int iCustomerId =Convert.ToInt32(context.Request["iUnid"]);
var cus = from q in _list
where q.Unid == iCustomerId
select q;

string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(cus);
context.Response.Write(strJson);

·ajax请求

 

function GetCustomer_AshxWithPara() {
$.getJSON(
"webdata/Json_2.ashx",
{ iUnid: 1 },
function(data) {
var tt = "";
$.each(data, function(k, v) {
$.each(v, function(kk, vv) {
tt += kk + ":" + vv + "<br/>";
});
});

$("#divmessage").html(tt);
});
}

其中参数也是以k/v对格式发出。请求返回的可以看到:在服务端以Customer列表集合返回。

 

在jquery库中,getJSON其实是调用的:Query.get(url, data, callback, "json")

这点很重要。

posted @ 2011-03-29 22:03 子午 阅读(279) 评论(0) 编辑
摘要: 用eclipse新建activity,其实就是一个java class,选项卡里面有很多资料,superclass这里需要修改android.app.Activity或者其他就成activity了.无法获取资源id,必须在onCreate(Bundle)后才能条用setContentView(int)来填充界面,这个方法的作用是填充ID所有指定的布局资源.findViewById必须在setContentView(int)之后。一个android应用程序可以包含多个activity,但只有一个activity用于启动,androidManifest.xml将这个Activity定义一个<阅读全文
posted @ 2011-03-25 10:58 子午 阅读(79) 评论(0) 编辑
摘要: http://bbs.bget.cn/index.php这玩意确实不错~省了好多事阅读全文
posted @ 2011-03-24 09:58 子午 阅读(12) 评论(0) 编辑
摘要: super.onCreate(paramBundle);setContentView(R.layout.splash_screen_view);final Intent localIntent=new Intent(this,Main.class);Timer timer=new Timer();TimerTask tast=new TimerTask(){@Overridepublic void run(){startActivity(localIntent);}};timer.schedule(tast,DELAY);阅读全文
posted @ 2011-03-04 16:26 子午 阅读(515) 评论(0) 编辑
摘要: 1.Screen size 屏幕实际尺寸。Android讲屏幕实际尺寸分为3个通用的尺寸。 2.Aspect ratio 长宽比 3.Resolution 分辨率 4.Density 密度 5.Density-independent pixel 密度无关的像素介绍:Adnroid1.6或以上SDK,在AndroidManifest.xml中提供新的一个元素<supports-screens>用于支持多屏幕机制。<supports-screens android:largeScreens="true" 是否支持大屏 android:normalScreens阅读全文
posted @ 2011-03-04 11:58 子午 阅读(1424) 评论(1) 编辑