Windows Live Writer的几种代码插件比较

来源:互联网 发布:淘宝宝贝描述下载 编辑:程序博客网 时间:2024/04/18 09:55
   2:   
   1: package org.androidin.tutorial.view;  
   3: import org.androidin.tutorial.LoginSuccessActivity;   
   4: import org.androidin.tutorial.R;  
   5:   
   6: import android.content.Context;   
   7: import android.content.Intent;   
   8: import android.os.Handler;   
   9: import android.view.View;   
  10: import android.widget.Toast;  
  11:   
  12: public class OnLoginListenerImpl implements OnLoginListener{   
  13: protected Object session; //用来保存一些登录状态的返回值,可以是HashMap,大家自己根据实际应用发挥了   
  14: protected Handler handler; //所有的这些方法都是在另一线程调用,所以Handler用来改变一些控件的属性。   
  15: public OnLoginListenerImpl(Handler handler) {   
  16: this.handler = handler;   
  17: }  
  18:   
  19: public boolean onLogin(View v, String username, String password) {   
  20: for (int i=0; i<10000000; i++) //此方法来模拟阻塞的Socket   
  21: ;   
  22: if(username.equals("androidin")) return true; //登录成功   
  23: return false; //登录失败   
  24: }  
  25:   
  26: public void onLoginFailed(final View v) {   
  27: handler.post(new Runnable() { //失败显示一个Toast   
  28: public void run() {   
  29: Toast.makeText(   
  30: v.getContext(),   
  31: v.getContext().getText(R.string.login_failed),   
  32: Toast.LENGTH_LONG).show();   
  33: }   
  34: });   
  35: }  
  36:   
  37: public void onLoginSuccess(View v) {   
  38: Context context = v.getContext();   
  39: context.startActivity(new Intent(context,   
  40: LoginSuccessActivity.class)); //跳转到成功页面   
  41: }   
  42: }  

上面这是CodeSnippet的效果

下面我们来看看SourceCodePlugin的表现:

TestLoginView.java   package org.androidin.tutorial;   import android.app.Activity;   import android.app.Dialog;   import android.content.Intent;   import android.os.Bundle;   import android.view.View;   import android.view.View.OnClickListener;   import android.widget.Button;   public class TestLoginView extends Activity {   /** Called when the activity is first created. */   public static Button btnActivity;   public static Button btnDialog;   public void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.main);   btnActivity = (Button)findViewById(R.id.test_activity);   btnActivity.setOnClickListener(new BtnActivityOnclikListener());   btnDialog = (Button)findViewById(R.id.test_dialog);   btnDialog.setOnClickListener(new BtnDialogOnClickListener());   }   
再加个插件(source Code Formatter),成了这种效果
TestLoginView.java   
package org.androidin.tutorial;   
import android.app.Activity;   
import android.app.Dialog;   
import android.content.Intent;   
import android.os.Bundle;   
import android.view.View;   
import android.view.View.OnClickListener;   
import android.widget.Button;   
public class TestLoginView extends Activity {   
/** Called when the activity is first created. */   
public static Button btnActivity;   
public static Button btnDialog;   
public void onCreate(Bundle savedInstanceState) {   
super.onCreate(savedInstanceState);   
setContentView(R.layout.main);   
btnActivity = (Button)findViewById(R.id.test_activity);   
btnActivity.setOnClickListener(new BtnActivityOnclikListener());   
btnDialog = (Button)findViewById(R.id.test_dialog);   
btnDialog.setOnClickListener(new BtnDialogOnClickListener());   
}  
下面再装个Insert Code for Windows Live Writer插件,支持语言较少,个人不感兴趣!
   1:  TestLoginView.java   
   2:  package org.androidin.tutorial;   
   3:  import android.app.Activity;   
   4:  import android.app.Dialog;   
   5:  import android.content.Intent;   
   6:  import android.os.Bundle;   
   7:  import android.view.View;   
   8:  import android.view.View.OnClickListener;   
   9:  import android.widget.Button;   
  10:  public class TestLoginView extends Activity {   
  11:  /** Called when the activity is first created. */   
  12:  public static Button btnActivity;   
  13:  public static Button btnDialog;   
  14:  public void onCreate(Bundle savedInstanceState) {   
  15:  super.onCreate(savedInstanceState);   
  16:  setContentView(R.layout.main);   
  17:  btnActivity = (Button)findViewById(R.id.test_activity);   
  18:  btnActivity.setOnClickListener(new BtnActivityOnclikListener());   
  19:  btnDialog = (Button)findViewById(R.id.test_dialog);   
  20:  btnDialog.setOnClickListener(new BtnDialogOnClickListener());   
  21:  }   
.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }
好吧,这就是Windows Live Writer几种代码插件的效果展示了!