hyljava

          2013年4月19日 #

          解決SoapUI的Request URL不支持大寫(xiě)

          在SoapUI的Request URL中,每次輸入的URL中含有的大寫(xiě)字母會(huì)自動(dòng)轉(zhuǎn)換為小寫(xiě)字母,導(dǎo)致請(qǐng)求不了
          這個(gè)問(wèn)題在SoapUI 5.1.2和5.2.1版本中都存在,具體的解決辦法是在HTTP TestRequest Properties的屬性中,在Endpoint中輸入對(duì)應(yīng)的含有大寫(xiě)字母的URL即可。



          posted @ 2017-03-23 10:27 何云隆 閱讀(401) | 評(píng)論 (0)編輯 收藏

          java發(fā)送郵件

          Java使用網(wǎng)易郵箱服務(wù)器發(fā)送郵件實(shí)例

          1 下載發(fā)送mail需要的jar

           

          activation.jar  與  mail.jar

           

          2 創(chuàng)建 SendMail  類(lèi)

          3 代碼如下

           

           

          import java.util.Date;

          import java.util.Properties;

          import javax.mail.Address;

          import javax.mail.Message;

          import javax.mail.Session;

          import javax.mail.Transport;

          import javax.mail.internet.InternetAddress;

          import javax.mail.internet.MimeMessage;

          import cn.founder.common.globals.Constants;

           

          public class SendMail {

          public int send(String tfrom, String tto, String ttitle, String tcontent) {

          Properties props = new Properties();

          props.put("mail.smtp.host", "smtp.263.net");//自己到網(wǎng)上查找網(wǎng)易發(fā)郵件的smtp服務(wù)地址 你的發(fā)件郵箱如果是163  你就查找163的發(fā)件服務(wù)器

          props.put("mail.smtp.auth", "true");

          Session s = Session.getInstance(props, null);

          s.setDebug(true);

          Message message = new MimeMessage(s);

          try {

          Address from = new InternetAddress(tfrom);

          message.setFrom(from);

          Address to = new InternetAddress(tto);

          message.setRecipient(Message.RecipientType.TO, to);

          sun.misc.BASE64Encoder enc = new sun.misc.BASE64Encoder();  

          message.setSubject("=?utf-8?B?"+enc.encode(ttitle.getBytes("utf-8"))+"?=");

          message.setContent(tcontent, "text/html;charset=utf-8");

          message.setSentDate(new Date());

          message.saveChanges();

          Transport transport = s.getTransport("smtp");

          //第一個(gè)參數(shù)是發(fā)件服務(wù)器   第二個(gè)是你發(fā)件的郵箱名  第三個(gè)是你發(fā)件郵箱的密碼

          transport.connect("smtp.263.net",發(fā)件郵箱,發(fā)件郵箱密碼);

          transport.sendMessage(message, message.getAllRecipients());

          transport.close();

          return 0;

          } catch (Exception e) {

          e.printStackTrace();

          return 1;

          }

          }

          /**

           * getEmailServiceIp

           * @return EmailServiceIp

           */

          public static void main(String[] args) {

          //第一個(gè)參數(shù) 發(fā)件郵箱   第二個(gè)收件郵箱  第三個(gè) 郵件內(nèi)容

            new SendMail().send("yunlong090614@163.com", "1063342004@qq.com", "更改密碼校驗(yàn)", "尊敬的用戶(hù)你好,您的校驗(yàn)碼為:65432</br>xxxx");

          }

          posted @ 2016-04-03 11:04 何云隆 閱讀(156) | 評(píng)論 (0)編輯 收藏

          jstl用系統(tǒng)時(shí)間進(jìn)行判斷數(shù)據(jù)時(shí)間

          <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
          <jsp:useBean id="now" class="java.util.Date" />

           <c:set var="currentday">
                  <fmt:formatDate value="${now}" type="both" dateStyle="long" pattern="yyyy-MM-dd" var="nowdate"/>
                  </c:set>
                  ${nowdate} > ${result.openEndTimeOpen }=${nowdate > result.openEndTimeOpen}
               

          posted @ 2015-10-09 09:57 何云隆 閱讀(391) | 評(píng)論 (0)編輯 收藏

          plsqldevelop連接到不到數(shù)據(jù)庫(kù)


          安裝32位的Oracle客戶(hù)端( instantclient-basic-win32-11.2.0.1.0)。Win7 64位系統(tǒng)暫無(wú)PLSQLDeveloper,所以下一個(gè)32位的。

            下載instantclient-basic-win32-11.2.0.1.0.zip (一定得是32位的,不要下錯(cuò)了版本,Oracle官網(wǎng)有下載),將其解壓至Oracle安裝目錄的Product下(本機(jī)命名為:instantclient_11_2):D:\Oracle\app\Dell\product\instantclient_11_2

          拷貝數(shù)據(jù)庫(kù)安裝根目錄下的一個(gè)文件夾:D:\Oracle\app\Dell\product\11.2.0\dbhome_1

          \NETWORK到Oracle客戶(hù)端目錄下D:\Oracle\app\Dell\product\instantclient_11_2(其實(shí)只需要 NETWORK\ADMIN\tnsnames.ora)



           修改oracle客戶(hù)端tnsnames.ora文件(目錄在D:\Oracle\app\Dell\product\instantclient_11_2\NETWORK\ADMIN\tnsnames.ora)
           MYACCP= (DESCRIPTION=       
          (ADDRESS_LIST=            
          (ADDRESS= (PROTOCOL=tcp)(HOST=superich-accp )(PORT=1521)) ) 
          (CONNECT_DATA=(SERVICE_NAME = ACCP)         
           ) )

          posted @ 2015-09-29 15:47 何云隆 閱讀(143) | 評(píng)論 (0)編輯 收藏

          SQL按照漢字排序

          SELECT createDate,shortName,collNum,fullName FROM college
          ORDER BY CONVERT( shortName USING gbk)

          posted @ 2015-09-01 13:25 何云隆 閱讀(399) | 評(píng)論 (0)編輯 收藏

          無(wú)法啟動(dòng)print spooler服務(wù),錯(cuò)誤1068

          近幾日打印東西都是不成功,顯示不能發(fā)現(xiàn)打印機(jī),處理方法如下:
          啟動(dòng) print spooler服務(wù) 但是報(bào)1068錯(cuò)誤,
          在運(yùn)行中輸入“sc config spooler depend= rpcss”,確定后,我再去啟用Print Spooler服務(wù),居然成功了。我也不知道這是個(gè)什么命令,但是問(wèn)題解決了,就要謝謝網(wǎng)絡(luò)上的高手們!

          posted @ 2015-08-30 08:10 何云隆 閱讀(185) | 評(píng)論 (0)編輯 收藏

          JSP中EL表達(dá)式三元(三目)運(yùn)算符的使用

          Java中的三元運(yùn)算符為:條件?條件為true值:條件為false的值
          EL也有一樣的運(yùn)算符,用EL的三元運(yùn)算符有時(shí)可以代替c:choose標(biāo)簽,為我們的工作省下很大力氣。

          比如gender為0顯示男,其余顯示女,我們可以這么寫(xiě):

          <c:choose>
          <c:when test="${gender eq 0}"></c:when>
          <c:otherwise></c:otherwise>
          </c:choose>

          但是不是顯得太麻煩了?其實(shí)我們這里就可以使用EL表達(dá)式中的三元運(yùn)算符了,上面可以簡(jiǎn)化為:

          ${gender eq 0?"男":"女"}

          這樣是不是簡(jiǎn)練了很多?在JSTL和EL處理非A即B的時(shí)候,三元運(yùn)算符簡(jiǎn)單了許多。

          轉(zhuǎn)載請(qǐng)注明:觀測(cè)者 » JSP中EL表達(dá)式三元運(yùn)算符的使用

          posted @ 2015-08-25 11:03 何云隆 閱讀(2733) | 評(píng)論 (0)編輯 收藏

          打 war包命令

          jar -cvf safety.war *
          打 war包命令

          posted @ 2015-08-19 10:18 何云隆 閱讀(133) | 評(píng)論 (0)編輯 收藏

          jquery校驗(yàn)輸入框內(nèi)容

               摘要:  引用地址http://www.cnblogs.com/xdp-gacl/p/3467245.html 用Jquery控制文本框只能輸入數(shù)字和字母   在公司開(kāi)發(fā)WinForm項(xiàng)目時(shí),發(fā)現(xiàn)公司自主研發(fā)的textbox控件非常強(qiáng)大,可以實(shí)現(xiàn)"只能輸入數(shù)字"、"只能輸入字母"和"只能輸入數(shù)字和字母"的三種輸入限制,這樣就可以精確控制用戶(hù)輸入的內(nèi)容范圍,讓"用戶(hù)永遠(yuǎn)沒(méi)有辦法輸入...  閱讀全文

          posted @ 2015-05-08 11:22 何云隆 閱讀(444) | 評(píng)論 (0)編輯 收藏

          svn更新失敗提示locked

          SVN更新失敗,提示locked

          • 瀏覽:3571
          • |
          • 更新:

           

          產(chǎn)生這種情況大多是因?yàn)樯洗蝧vn命令執(zhí)行失敗且被鎖定了,需要?jiǎng)h除文件夾中的lock文件,即可解鎖。這里介紹3種方法:

          方法一.直接進(jìn)行cleanup;對(duì)較小的文件比較管用,文件稍大些等待時(shí)間很長(zhǎng)或不起作用;

           

          方法二.選擇文件,右鍵執(zhí)行release lock;等待時(shí)間較長(zhǎng);

           

          方法三.手動(dòng)刪除鎖定文件:

           1.在運(yùn)行中輸入cmd進(jìn)入命令行; 2.在命令提示符下cd 到svn項(xiàng)目出現(xiàn)問(wèn)題的文件所在目錄下; 3.執(zhí)行命令del lock /q/s 4.等待刪除lock文件成功,重新更新SVN。

          posted @ 2015-03-25 15:03 何云隆 閱讀(291) | 評(píng)論 (0)編輯 收藏

          廣禾養(yǎng)老文化村

          廣禾養(yǎng)老文化村
          首頁(yè)地址http://202.199.162.210:8080/IntelligentNursing/index/toIndex
          展示效果

           
           


          posted @ 2014-08-26 16:18 何云隆| 編輯 收藏

          打開(kāi)eclipse彈出Error:could not open D:\java\lib\i386\jvm.cfg'

          打開(kāi)eclipse彈出Error:could not open D:\java\lib\i386\jvm.cfg'
          運(yùn)行中 輸入regedit 
           
          沒(méi)有修改注冊(cè)表,解決辦法是: 
          重新安裝JDK時(shí)注冊(cè)表中\(zhòng)HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environemt\1.6 項(xiàng)目下的JavaHome和RuntimeLib設(shè)置沒(méi)有更新,將這兩個(gè)項(xiàng)目更正即可.
           
           

          posted @ 2014-05-24 22:05 何云隆 閱讀(547) | 評(píng)論 (0)編輯 收藏

          安裝Eclipse Html Editor

          安裝Eclipse Html Editor 轉(zhuǎn)

          分類(lèi): Java 1431人閱讀 評(píng)論(0) 收藏 舉報(bào)
            最近在eclipse中開(kāi)發(fā)android項(xiàng)目,用到了jquery mobile框架,則會(huì)涉及到新建html文件,發(fā)現(xiàn)eclipse不自帶新建html文件的插件,必須得新建一個(gè)其他形式的文件,譬如xml格式的文件,然后重命名,后綴名改成html,覺(jué)得這樣老麻煩的,所以在網(wǎng)上發(fā)現(xiàn)了Eclipse HTML Editor,不過(guò)此插件似乎只支持新建html文件,不支持其格式化。網(wǎng)上看了其他一個(gè)html格式化的插件Eclipse Tidy,不過(guò)用了后,發(fā)現(xiàn)格式化后的html一點(diǎn)都不符合代碼審讀標(biāo)準(zhǔn)。也不知道是不是自己哪邊沒(méi)設(shè)置好,還是本來(lái)就是那樣。

             現(xiàn)在就暫先不管Eclipse Tidy了,看看如何安裝Eclipse HTML Editor。

          1.下載GEF(依賴(lài)包):

          http://www.eclipse.org/downloads/download.php?file=/tools/gef/downloads/drops/3.7.2/R201201171043/GEF-ALL-3.7.2.zip

          然后解壓,把解壓得到的features和plugins兩文件夾放到eclipse安裝目錄下plugins文件夾中

          2.下載HTMLEditor

          http://amateras.sourceforge.jp/cgi-bin/fswiki_en/wiki.cgi?page=EclipseHTMLEditor

          只有一個(gè)tk.eclipse.plugin.htmleditor_2.1.0.jar文件

          直接復(fù)制到eclipse\plugins里面

          posted @ 2014-04-03 15:15 何云隆 閱讀(176) | 評(píng)論 (0)編輯 收藏

          mysql 解決全連接問(wèn)題

               摘要: 基本資料:mysql> select version();+-----------+| version() |+-----------+| 5.0.16 |+-----------+ mysql> select * from t1;+----+------+| id | name |+----+------+| 1 | aa || 2 | bb || 3 | cc |+---...  閱讀全文

          posted @ 2014-03-03 19:30 何云隆 閱讀(350) | 評(píng)論 (0)編輯 收藏

          ListView實(shí)現(xiàn)RadioButton的功能有bug改進(jìn)

          前言:之前做的ListView實(shí)現(xiàn)RadioButton的功能有bug,當(dāng)ListView控件的內(nèi)容超出屏幕可見(jiàn)區(qū)域時(shí),滑動(dòng)ListView控件會(huì)報(bào)錯(cuò),下面有為什么出錯(cuò)和解決方法進(jìn)行的注解,不多說(shuō)了,看源碼,有更好的解決辦法請(qǐng)指教

          1,MainActivity.java

          package com.excetop.listradio;

          import android.app.Activity;
          import android.os.Bundle;
          import android.util.Log;
          import android.view.View;
          import android.view.ViewGroup;
          import android.widget.BaseAdapter;
          import android.widget.Button;
          import android.widget.CompoundButton;
          import android.widget.ListView;
          import android.widget.RadioButton;
          import android.widget.CompoundButton.OnCheckedChangeListener;

          public class MainActivity extends Activity {
              private static final String TAG = "MainActivity";
              private ListView listView;
              @Override
              public void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.main);
                  listView = (ListView) this.findViewById(R.id.list);
                  MyAdapter adapter = new MyAdapter();
                  listView.setAdapter(adapter);
              }
              private class MyAdapter extends BaseAdapter{
                  private String[] s = new String[]{"a","b","c","d","e","a","b","c","d","e","a","b","c","d","e","a","b","c","d","e"};
                  private int temp = -1;

                  @Override
                  public int getCount() {
                      // TODO Auto-generated method stub
                      return s.length;
                  }

                  @Override
                  public Object getItem(int position) {
                      // TODO Auto-generated method stub
                      return null;
                  }

                  @Override
                  public long getItemId(int position) {
                      // TODO Auto-generated method stub
                      return 0;
                  }

                  @Override
                  public View getView(int position, View convertView, ViewGroup parent) {
                      convertView = MainActivity.this.getLayoutInflater().inflate(R.layout.item, null);  //解決辦法: 每次都重新獲取View
                      Button button = (Button) convertView.findViewById(R.id.button);
                      button.setText(s[position]);
                      RadioButton radioButton = (RadioButton) convertView.findViewById(R.id.radioButton);
                      radioButton.setId(position);  //把position設(shè)為radioButton的id
                      radioButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                          
                          @Override
                          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                              
                              if(isChecked){
                                  //這段代碼來(lái)實(shí)現(xiàn)單選功能
                                  if(temp != -1){
                                      RadioButton tempButton = (RadioButton) MainActivity.this.findViewById(temp);
                                      if(tempButton != null){
                                         tempButton.setChecked(false);
                                      }
                                      
                                  }
                                  
                                  temp = buttonView.getId();
                                  Log.i(TAG,"you are women- -   " + isChecked + "   " + temp);
                                  
                              }
                          }
                      });
                      
                      //這里實(shí)現(xiàn)單選框選的回顯,解決了單選框移出屏幕范圍未選中狀態(tài)
                      if(temp == position){
                          radioButton.setChecked(true);
                      }
                      return convertView;
                  }
          //            Holder holder;
          //            if(convertView == null){    //1,當(dāng)?shù)谝淮渭虞dListView控件時(shí)  convertView為空 
          //                convertView = MainActivity.this.getLayoutInflater().inflate(R.layout.item, null); //所以當(dāng)ListView控件沒(méi)有滑動(dòng)時(shí)都會(huì)執(zhí)行這條語(yǔ)句
          //                holder = new Holder();
          //                convertView.setTag(holder);
          //            }else{
          //                holder = (Holder) convertView.getTag();
          //            }
          //            
          //            holder.button = (Button) convertView.findViewById(R.id.button);
          //            holder.button.setText(s[position]);
          //            
          //            holder.radioButton = (RadioButton) convertView.findViewById(R.id.radioButton);   //
          //            holder.radioButton.setId(position);  //2,因?yàn)檫@里對(duì)radioButton的id進(jìn)行重新設(shè)置,滑動(dòng)ListView時(shí)convertView不為空,上面的語(yǔ)句就沒(méi)法得到radioButton對(duì)象,這條語(yǔ)句就會(huì)報(bào)空指針異常
                    
          //            holder.radioButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
          //                
          //                @Override
          //                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
          //                    
          //                    if(isChecked){
          //                        if(temp != -1){
          //                            RadioButton tempButton = (RadioButton) MainActivity.this.findViewById(temp);
          //                            tempButton.setChecked(false);
          //                            
          //                        }
          //                        
          //                        temp = buttonView.getId();
          //                        Log.i(TAG,"you are women- -   " + isChecked + "   " + temp);
          //                        
          //                    }
          //                }
          //            });
          //            return convertView;
          //        }
          //        private class Holder{
          //            private Button button;
          //            private RadioButton radioButton;
          //        }
              }
          }

          2,item.xml

          <?xml version="1.0" encoding="utf-8"?>
          <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <Button
              android:id="@+id/button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="測(cè)試">
            
            </Button>
            
            <RadioButton
              android:id="@+id/radioButton"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              />  
           
          </LinearLayout>
          3, main.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"
              />
              <ListView
                 android:id="@+id/list"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 />
          </LinearLayout>

          posted @ 2014-02-22 22:58 何云隆 閱讀(258) | 評(píng)論 (0)編輯 收藏

          listview與checkbox組合使用

          一,Layout

           

          1,main.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"
              />
              <ListView
                 android:id="@+id/list"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 />
          </LinearLayout>

           

          2,item.xml

          <?xml version="1.0" encoding="utf-8"?>
          <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <Button
              android:id="@+id/button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="測(cè)試">
            
            </Button>
            
            <CheckBox
              android:id="@+id/checkBox"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              />  
           
          </LinearLayout>

          二,Activity

           

          1,MainActivity

          package com.excetop.listradio;

          import java.util.ArrayList;
          import java.util.HashMap;
          import java.util.List;
          import java.util.Map;

          import android.app.Activity;
          import android.os.Bundle;
          import android.util.Log;
          import android.view.View;
          import android.view.ViewGroup;
          import android.widget.BaseAdapter;
          import android.widget.Button;
          import android.widget.CheckBox;
          import android.widget.CompoundButton;
          import android.widget.ListView;
          import android.widget.Toast;
          import android.widget.CompoundButton.OnCheckedChangeListener;

          public class MainActivity extends Activity {
           private static final String TAG = "MainActivity";
              private ListView listView;
              private Map checkMap;
           @Override
              public void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.main);
                  listView = (ListView) this.findViewById(R.id.list);
                  
                  checkMap = new HashMap<String, Object>();
                  
                  MyAdapter adapter = new MyAdapter();
                  listView.setAdapter(adapter);
                
              }
           private class MyAdapter extends BaseAdapter{
            private String[] s = new String[]{"a","b","c","d","e","a","b","c","d","e","a","b","c","d","e","a","b","c","d","e"};

            @Override
            public int getCount() {
             // TODO Auto-generated method stub
             return s.length;
            }

            @Override
            public Object getItem(int position) {
             // TODO Auto-generated method stub
             return null;
            }

            @Override
            public long getItemId(int position) {
             // TODO Auto-generated method stub
             return 0;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
             convertView = MainActivity.this.getLayoutInflater().inflate(R.layout.item, null);  //解決辦法: 每次都重新獲取View
             Button button = (Button) convertView.findViewById(R.id.button);
             button.setText(s[position]);
             final CheckBox checkBox =  (CheckBox) convertView.findViewById(R.id.checkBox);
             checkBox.setId(position);  //把position設(shè)為radioButton的id
             checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
              
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
               
               if(isChecked){
                
                checkMap.put(String.valueOf(checkBox.getId()), checkBox.getId());
          //      Toast.makeText(MainActivity.this, String.valueOf( checkBox.getId()), 0).show();
               
               }else{
                checkMap.remove(String.valueOf(checkBox.getId()));
          //      Toast.makeText(MainActivity.this, String.valueOf( checkBox.getId()), 0).show();
               }
              }
             });
             
             if(checkMap.get(String.valueOf(position)) != null){
              checkBox.setChecked(true);
          //    Toast.makeText(MainActivity.this, String.valueOf(String.valueOf(position)), 0).show();
             }
             
             //這里實(shí)現(xiàn)單選框選的回顯,解決了單選框移出屏幕范圍未選中狀態(tài)
             return convertView;
            }
           }
          }

          posted @ 2014-02-22 22:56 何云隆 閱讀(221) | 評(píng)論 (0)編輯 收藏

          處理多個(gè)fragment之間replace刷新問(wèn)題

           處理多個(gè)fragment之間replace刷新問(wèn)題[轉(zhuǎn)]
           每次創(chuàng)建fragment對(duì)象都會(huì)重新走onCreateView方法,所以多個(gè)fragment互相替換會(huì)重新刷新界面,
           在application中創(chuàng)建一個(gè)View,保持onCreateVIew中創(chuàng)建的View
           每次走onCreateView的時(shí)候判斷application中是否保持了View,如果為null,重新inflater走initView和initData方法,不為nul得到父類(lèi),移除子View,不然有父id無(wú)法再加入布局中,
           以下是代碼:
           @Override
           public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
            
            GalaxyApplication galaxyApplication = (GalaxyApplication) getActivity().getApplication();
            View recommendView = galaxyApplication.getRecommendView();
            if(recommendView != null){
             
             ViewGroup group = (ViewGroup) recommendView.getParent();
             group.removeAllViews();
             
             return recommendView;
            }
            
            View fmRootView = inflater.inflate(R.layout.fragment_recommend, container,false);
            
            
           
            
            initView(fmRootView);
            initData();
            galaxyApplication.setRecommendView(fmRootView);
            Logger.d("fragment: ", "onCreateView");
            return fmRootView;
           } 

           如有好的方法,處理onCreateView刷新問(wèn)題  歡迎留言。 

          posted @ 2014-02-22 22:55 何云隆 閱讀(555) | 評(píng)論 (0)編輯 收藏

          android設(shè)置重復(fù)背景

          創(chuàng)建重復(fù)的背景圖片


          在drawable目錄下創(chuàng)建一個(gè)repeat_bg.xml:  src是引用圖片的名稱(chēng)

          1
          2
          3
          4
          5
          6
          7
          8
          1
          <?xml version="1.0" encoding="utf-8"?>
          2
          <bitmap xmlns:android="
          3
              android:src="@drawable/bg"
          4
              android:tileMode="repeat" />

          然后在布局的xml文件中可以這樣引用:

          1
          2
          3
          4
          5
          6
          7
          8
          1
          <LinearLayout android:layout_width="fill_parent"
          2
              android:layout_height="fill_parent"
          3
              android:background="@drawable/repeat_bg">
          4
          </LinearLayout>

          posted @ 2014-02-16 09:59 何云隆 閱讀(204) | 評(píng)論 (0)編輯 收藏

          SQL Server 里面的生成SQL腳本

          通常情況下,SQL Server里面的生成SQL腳本,只會(huì)包含數(shù)據(jù)庫(kù)及表的字段結(jié)構(gòu),而不會(huì)包含表的數(shù)據(jù),也就是SQL腳本里面只有Create database,Create table 這樣的語(yǔ)句,沒(méi)有insert into。
          因?yàn)镾QL Server并不包含這個(gè)功能,只能靠第三方的代碼了。
          以下存儲(chǔ)過(guò)程可以實(shí)現(xiàn):
          CREATE PROCEDURE dbo.UspOutputData
          @tablename sysname
          AS
          declare @column varchar(1000)
          declare @columndata varchar(1000)
          declare @sql varchar(4000)
          declare @xtype tinyint
          declare @name sysname
          declare @objectId int
          declare @objectname sysname
          declare @ident int
          set nocount on
          set @objectId=object_id(@tablename)
          if @objectId is null -- 判斷對(duì)象是否存在
          begin
          print 'The object not exists'
          return
          end
          set @objectname=rtrim(object_name(@objectId))
          if @objectname is null or charindex(@objectname,@tablename)=0 --此判斷不嚴(yán)密
          begin
          print 'object not in current database'
          return
          end
          if OBJECTPROPERTY(@objectId,'IsTable') < > 1 -- 判斷對(duì)象是否是table
          begin
          print 'The object is not table'
          return
          end
          select @ident=status&0x80 from syscolumns where id=@objectid and status&0x80=0x80
          if @ident is not null
          print 'SET IDENTITY_INSERT '+@TableName+' ON'
          declare syscolumns_cursor cursor
          for select c.name,c.xtype from syscolumns c where c.id=@objectid order by c.colid
          open syscolumns_cursor
          set @column=''
          set @columndata=''
          fetch next from syscolumns_cursor into @name,@xtype
          while @@fetch_status < >-1
          begin
          if @@fetch_status < >-2
          begin
          if @xtype not in(189,34,35,99,98) --timestamp不需處理,image,text,ntext,sql_variant 暫時(shí)不處理
          begin
          set @column=@column+case when len(@column)=0 then'' else ','end+@name
          set @columndata=@columndata+case when len(@columndata)=0 then '' else ','','','
          end
          +case when @xtype in(167,175) then '''''''''+'+@name+'+''''''''' --varchar,char
          when @xtype in(231,239) then '''N''''''+'+@name+'+''''''''' --nvarchar,nchar
          when @xtype=61 then '''''''''+convert(char(23),'+@name+',121)+''''''''' --datetime
          when @xtype=58 then '''''''''+convert(char(16),'+@name+',120)+''''''''' --smalldatetime
          when @xtype=36 then '''''''''+convert(char(36),'+@name+')+''''''''' --uniqueidentifier
          else @name end
          end
          end
          fetch next from syscolumns_cursor into @name,@xtype
          end
          close syscolumns_cursor
          deallocate syscolumns_cursor
          set @sql='set nocount on select ''insert '+@tablename+'('+@column+') values(''as ''--'','+@columndata+','')'' from '+@tablename
          print '--'+@sql
          exec(@sql)
          if @ident is not null
          print 'SET IDENTITY_INSERT '+@TableName+' OFF'
          GO
           
          使用方法:
          exec UspOutputData 你的表名
          選擇【執(zhí)行模式】為“以文本顯示結(jié)果”,然后將運(yùn)行后的結(jié)果存成.sql,加上用SQL Server生成的數(shù)據(jù)庫(kù)腳本就可以了。
          另外可以利用第三方工具,導(dǎo)出數(shù)據(jù)可以用powerbuilder。在database painter里面,用SQL選出,或者直接打開(kāi)表,點(diǎn)擊生成的list datawindow,然后在菜單file->save rows as->選擇SQL,那么生成的SQL語(yǔ)句就包括建表和insert數(shù)據(jù)的SQL了。

          轉(zhuǎn)載:http://blog.sina.com.cn/s/blog_49b531af0100i74v.html

          posted @ 2014-01-09 13:34 何云隆 閱讀(138) | 評(píng)論 (0)編輯 收藏

          CompoundButton

          Android 中文 API (29) —— CompoundButton


          前言

            本章內(nèi)容是android.widget.CompoundButton,翻譯來(lái)自德羅德,再次感謝德羅德 !期待你一起參與Android API 的中文翻譯,聯(lián)系我over140@gmail.com。 

           

            轉(zhuǎn)載

           

           正文

            一、結(jié)構(gòu)

              public abstract class CompoundButton extends Button implements Checkable

           

              java.lang.Object
                android.view.View
                  android.widget.TextView
                    android.widget.Button
                      android.widget.CompoundButton

           

            二、概述

              一個(gè)帶有選中/未選中狀態(tài)的按鈕。當(dāng)按鈕按下或點(diǎn)中時(shí)自動(dòng)改變狀態(tài)。

           

            三、公共方法

                   public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)

                   在子視圖的構(gòu)建時(shí)分派一個(gè)輔助事件。(譯者注:通過(guò)源碼可以看出,視圖構(gòu)建時(shí)設(shè)置其選中狀態(tài)。)

                             參數(shù)

                                      event       事件

                             返回值

                                      如果事件全部完成返回True

           

                   public boolean isChecked ()

                   (譯者注:是否選中)

           

                   public void onRestoreInstanceState (Parcelable state)

                   允許視圖重新應(yīng)用以前通過(guò)onSaveInstanceState()生成代表內(nèi)部的狀態(tài)。這個(gè)函數(shù)決不調(diào)用一個(gè)空的狀態(tài)。

                             參數(shù)

                                      state       返回以前調(diào)用onSaveInstanceState()保存下來(lái)的狀態(tài)。

           

                   public Parcelable onSaveInstanceState ()

                   允許視圖生成一個(gè)代表內(nèi)部的狀態(tài),以后可用于創(chuàng)建一個(gè)與之相同的新的實(shí)例。這種狀態(tài)應(yīng)該只包含非持久或以后不能夠重建的信息。例如,你決不存儲(chǔ)你當(dāng)前在屏幕上的位置,因?yàn)檫@會(huì)在視圖的層面上重新計(jì)算放置一個(gè)新的實(shí)例。

                   你可以存儲(chǔ)到這里的一些例子:一個(gè)文本框中當(dāng)前光標(biāo)的位置(但通常不是文字本身,文字通常保存在內(nèi)容提供者(content provider)或其他持久的儲(chǔ)存中),一個(gè)列表視圖中的當(dāng)前選中項(xiàng)。

                             返回值

                                      返回一個(gè)包含視圖當(dāng)前狀態(tài)的Parcelable對(duì)象,或沒(méi)有什么狀態(tài)保存時(shí)返回null。默認(rèn)實(shí)現(xiàn)返回null

           

                   public boolean performClick ()

                   如果視圖定義了OnClickListener監(jiān)聽(tīng)器,調(diào)用此方法來(lái)執(zhí)行。

                             返回值

                                      定義了的OnClickListener被調(diào)用返回True,否則返回False

           

                   public void setButtonDrawable (Drawable d)

                   給按鈕背景設(shè)置一個(gè)可繪制對(duì)象(如:圖像)

                             參數(shù)

                                      d      用作背景的可繪制對(duì)象(如:圖像)

           

                   public void setButtonDrawable (int resid)

                   通過(guò)資源Id給按鈕背景設(shè)置一個(gè)圖像

                             參數(shù)

                                      resid        作為背景圖像的資源id

           

                   public void setChecked (boolean checked)

                   改變按鈕的選中狀態(tài)

                            參數(shù)

                                      checked true選中,false非選中

           

                   public void setOnCheckedChangeListener (CompoundButton.OnCheckedChangeListener listener)

                   注冊(cè)一個(gè)在按鈕狀態(tài)發(fā)生改變時(shí)執(zhí)行的回調(diào)函數(shù)

                             參數(shù)

                                      listener  當(dāng)選中狀態(tài)改變時(shí)調(diào)用的函數(shù)

           

                   public void toggle ()

                   改變選中狀態(tài)為當(dāng)前狀態(tài)的逆狀態(tài)

           

            四、受保護(hù)方法

                   protected void drawableStateChanged ()

                   在視圖狀態(tài)的變化影響到所顯示可繪制的狀態(tài)時(shí)調(diào)用這個(gè)方法。

          確保在重載時(shí)中調(diào)用父類(lèi)方法

           

                   protected int[] onCreateDrawableState (int extraSpace)

                   為當(dāng)前視圖生成新的可繪圖區(qū)狀態(tài)。這個(gè)方式當(dāng)緩存的圖像繪圖區(qū)狀態(tài)確定失效時(shí)通過(guò)視圖系統(tǒng)調(diào)用。你可以使用getDrawableState()方法重新取得當(dāng)前的狀態(tài)。

                             參數(shù)

                                      extraSpace      如果為非零,這是你應(yīng)該返回的數(shù)組在你可以存放你的狀態(tài)的額外條目的數(shù)量。

                             返回值

                                      返回一個(gè)記錄著視圖中當(dāng)前繪圖區(qū)狀態(tài)的數(shù)組

           

                   protected void onDraw (Canvas canvas)

                   實(shí)現(xiàn)你自己的繪制。

                             參數(shù)

                                      canvas    在畫(huà)布上繪制背景

           

                   protected boolean verifyDrawable (Drawable who)

                   如果你的視圖子類(lèi)顯示他自己的可視化對(duì)象,他將要重寫(xiě)此方法并且為了顯示可繪制返回true。此操作允許進(jìn)行繪制時(shí)有動(dòng)畫(huà)效果。

            確認(rèn)當(dāng)重寫(xiě)從方法時(shí),需調(diào)用父類(lèi)相應(yīng)方法。

                             參數(shù)

                                      who         需判斷的可繪制對(duì)象(Drawable)。如果是你要顯示的對(duì)象,返回True,否則返回調(diào)用父類(lèi)的結(jié)果。

                             返回值

                                      boolean 如果可繪制對(duì)象(Drawable)已經(jīng)在視圖中顯示,返回True否則返回false。并且此處不允許使用動(dòng)畫(huà)。 

          posted @ 2013-12-20 22:43 何云隆 閱讀(183) | 評(píng)論 (0)編輯 收藏

          eclipse集成maven

          1.eclipse集成maven
          http://eclipse.org/m2e/download/
          maven在線(xiàn)更新地址與下載插件地址
          2.下載maven 并且在機(jī)器上配置環(huán)境變量到bin目錄下;
          3.

          posted @ 2013-12-19 19:55 何云隆 閱讀(146) | 評(píng)論 (0)編輯 收藏

          周鴻祎-----把自己當(dāng)成打工的,一輩子都是打工的

          別人覺(jué)得你是不是在打工,這個(gè)不重要。重要的是你自己千萬(wàn)別把自己當(dāng)成打工的,換個(gè)角度去看,是公司給你發(fā)工資,替你交學(xué)費(fèi),練著你自己的能力和經(jīng)驗(yàn)。你遇到產(chǎn)品經(jīng)理、技術(shù)高手,或者公司創(chuàng)始人,從他們身上學(xué)到成功的經(jīng)驗(yàn),甚至是失敗的教訓(xùn)。

           

          我覺(jué)得有的人對(duì)創(chuàng)業(yè)的理解有誤區(qū)。他們把創(chuàng)業(yè)理解成幾個(gè)哥們開(kāi)一個(gè)公司,回去印幾盒名片,我叫董事局主-席,你叫首席執(zhí)行官,自己的同學(xué)脖子上都掛上個(gè)CXO,名字很洋氣,也不知道什么意思。如果把這個(gè)理解為創(chuàng)業(yè)就大錯(cuò)特錯(cuò)。

          我希望大家這樣來(lái)理解創(chuàng)業(yè),把創(chuàng)業(yè)看成是一種心態(tài),為了實(shí)現(xiàn)一個(gè)目標(biāo),孜孜不倦的去追求。只要你不滿(mǎn)足于現(xiàn)狀,想法設(shè)法去突破,那就是創(chuàng)業(yè)。如果你是一個(gè)在校學(xué)生,是搞電腦,如果你不滿(mǎn)足于只是把學(xué)分學(xué)好,不滿(mǎn)足于把考試應(yīng)付好,而是花了很多時(shí)間提高你的編程能力,下了很大功夫來(lái)研究很多軟件,那這也是創(chuàng)業(yè)。學(xué)習(xí)是這樣,工作也是這樣,只要你勇敢的正視問(wèn)題,積極的去解決問(wèn)題,敢于去承擔(dān)未來(lái)的風(fēng)險(xiǎn),這其實(shí)就是創(chuàng)業(yè)心態(tài)。

          如果我們把創(chuàng)業(yè)都理解成我今天出去成立一個(gè)公司,明天上市,后天市值超越Facebook,對(duì)不起,從來(lái)沒(méi)有過(guò)這樣成功的例子。天底下哪里有這么一帆風(fēng)順的事?把你放在一馬平川的大平原上,你憑著直覺(jué)沿著直線(xiàn)走,其實(shí)從高空看下去,你走出來(lái)的路是彎的,是曲折的。創(chuàng)業(yè)也是一樣,雖然心里有個(gè)目標(biāo),但是要達(dá)到那個(gè)目標(biāo),你得解決一個(gè)個(gè)實(shí)際的問(wèn)題。人的路都是一步一步走出來(lái)的,而且這個(gè)路一定不是直線(xiàn)。

          在中國(guó)更是這樣,環(huán)境確實(shí)太復(fù)雜了。特別是在創(chuàng)業(yè)早期,你沒(méi)有經(jīng)驗(yàn),沒(méi)有資源,你頭腦里的創(chuàng)新可能僅僅就是一個(gè)想法,一個(gè)主意,但如果實(shí)現(xiàn)不了,那它就什么都不是。但是,要實(shí)現(xiàn)這個(gè)想法,這個(gè)主意,你需要有判斷力,需要有經(jīng)驗(yàn),需要有知識(shí)。所以,我一直提倡大學(xué)生剛畢業(yè)的時(shí)候,不要頭腦一熱就攢出一個(gè)公司來(lái),最好的方法是加入一家創(chuàng)業(yè)公司,甚至可以加入風(fēng)險(xiǎn)很大的種子公司,去學(xué)習(xí)創(chuàng)業(yè),感受創(chuàng)業(yè)。

          很多人說(shuō),我加入別人的公司,那我不就成了一個(gè)打工的了嗎?給別人打工,誰(shuí)認(rèn)真干呀。錯(cuò)了,如果你覺(jué)得自己是打工的,那你一輩子都是打工的。別人覺(jué)得你是不是在打工,這個(gè)不重要。重要的是你自己千萬(wàn)別把自己當(dāng)成打工的,換個(gè)角度去看,是公司給你發(fā)工資,替你交學(xué)費(fèi),練著你自己的能力和經(jīng)驗(yàn)。你遇到產(chǎn)品經(jīng)理、技術(shù)高手,或者公司創(chuàng)始人,從他們身上學(xué)到成功的經(jīng)驗(yàn),甚至是失敗的教訓(xùn)。

          如果你加入這個(gè)公司,這個(gè)公司兩年之后死了,恭喜你,你一分錢(qián)沒(méi)損失,你參與一個(gè)活生生的公司從生到死的例子,你以后就可以避免重蹈覆轍。你一分錢(qián)沒(méi)花,你讓一個(gè)公司死了一回,你學(xué)到了如何避免失敗的教訓(xùn),這是一個(gè)多么值的事。這比你拿多少工資,比你到一個(gè)有名的大公司,有用多了。

          別人一見(jiàn)你,都說(shuō)你在北京某大公司工作,太了不起。那都是虛榮心,一點(diǎn)意義沒(méi)有。所以我一直強(qiáng)調(diào),如果你懷著創(chuàng)業(yè)的心態(tài),那么你在什么狀態(tài)都可以叫創(chuàng)業(yè)。等到有一天,當(dāng)你有一股強(qiáng)烈的沖動(dòng)要辦公司去創(chuàng)業(yè)的時(shí)候,有可能你會(huì)發(fā)現(xiàn),人各有所長(zhǎng),你不一定是做CEO的料,但你可能是優(yōu)秀的CTO,你可能是很好的銷(xiāo)售主管,這個(gè)時(shí)候你就知道找什么樣的合伙人去創(chuàng)業(yè)了。

          所以,我鼓勵(lì)大家創(chuàng)業(yè),其實(shí)是鼓勵(lì)大家培養(yǎng)創(chuàng)業(yè)的精神,我不主張各位一定要出去成立一個(gè)公司,那只是一個(gè)形式。美國(guó)硅谷很多人不是先裝模作樣地成立一個(gè)公司,而是在家里的車(chē)庫(kù),利用業(yè)余時(shí)間先搞出來(lái)一個(gè)產(chǎn)品,這也是創(chuàng)業(yè)的一部分。

          我不希望傳授什么成功學(xué),我最希望大家能夠想清楚未來(lái)幾年自己心里想要什么。在你創(chuàng)業(yè)的時(shí)候,不論遇到誘惑還是遇到挑戰(zhàn),都能夠記住我說(shuō)的那句話(huà):拒絕平庸,與眾不同。你不一定要追隨當(dāng)時(shí)的主流,也要能耐得住寂寞,甚至要有一種韌性,敢于屢敗屢戰(zhàn),在未來(lái)長(zhǎng)達(dá)五年或者八年、十年的時(shí)間里一直堅(jiān)韌不拔地去探索,我相信五年以后、十年以后,可能中國(guó)新一代的企業(yè)家,中國(guó)新一代的創(chuàng)新領(lǐng)袖應(yīng)該從各位里面誕生。

          posted @ 2013-12-18 22:24 何云隆 閱讀(165) | 評(píng)論 (0)編輯 收藏

          android library projects cannot be launched

          android library projects cannot be launched

           
          properties 在android選項(xiàng)中將 is library中將前面的勾去了

          posted @ 2013-12-14 23:04 何云隆 閱讀(145) | 評(píng)論 (0)編輯 收藏

          向ListView中添加數(shù)據(jù)

          BaseAdapter方式
          activity_main.xml

          <LinearLayout xmlns:android="    xmlns:tools="    xmlns:android1="    android:layout_width="match_parent"
              android:layout_height="match_parent" >

              <ListView
                  android1:id="@+id/listView1"
                  android1:layout_width="match_parent"
                  android1:layout_height="wrap_content"
                  android1:layout_weight="1" >
              </ListView>

          </LinearLayout>

          list_item.xml

          <?xml version="1.0" encoding="utf-8"?>
          <LinearLayout xmlns:android="
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="horizontal"
              android:gravity="center_vertical"
              android:id="@+id/waibubuju"
              >
             
              <TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/bianhao"
                  android:text="編號(hào)"
                  android:textColor="#88ff0000"
                  android:gravity="center"
                   android:textSize="18sp"
                  />
              <LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"
                  android:id="@+id/neibubuju"
                  >
                  <TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="姓名"  
                 android:id="@+id/username"
                     
                      />
           MainActivity.java

          package com.hyl.listViewpack;

          import java.util.ArrayList;

          import android.R.string;
          import android.os.Bundle;
          import android.app.Activity;
          import android.util.Log;
          import android.view.Menu;
          import android.view.View;
          import android.view.ViewGroup;
          import android.widget.Adapter;
          import android.widget.BaseAdapter;
          import android.widget.ListView;
          import android.widget.ScrollView;
          import android.widget.TextView;

          public class MainActivity extends Activity {
           protected static final String TAG = "MainActivity";
           private ListView listView1;
           ArrayList<ArrayList<String>> arr ;
           
           protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            listView1=(ListView) findViewById(R.id.listView1);
            arr=new ArrayList<ArrayList<String>>();
            for(int i=0;i<=50;i++){
             ArrayList<String> a=new ArrayList<String>();
             a.add("編號(hào):"+i);
             a.add("姓名:"+i);
             a.add("電話(huà):"+i);
             arr.add(a);
             
             
            }
            
            listView1.setAdapter(new  BaseAdapter() {
             
             
             public View getView(int position, View convertView, ViewGroup parent) {
              //父窗體 掛載 
              
              
              View view=View.inflate(MainActivity.this, R.layout.list_item, null);
           
              
              Log.e(TAG, "測(cè)試創(chuàng)建對(duì)象位置:"+position);
              
              
              ArrayList<String> a=arr.get(position);
              
              TextView tvbianhao=(TextView) view.findViewById(R.id.bianhao);
              tvbianhao.setText( a.get(0));
              
              TextView tvUserName=(TextView) view.findViewById(R.id.username);
              tvUserName.setText( a.get(1));
              
              TextView tvTel=(TextView) view.findViewById(R.id.tel);
              tvTel.setText( a.get(2));
              
              
              
              return view;
             }
             
             @Override
             public long getItemId(int position) {
              // TODO Auto-generated method stub
              return 0;
             }
             
             @Override
             public Object getItem(int position) {
              // TODO Auto-generated method stub
              return null;
             }
             
             @Override
             public int getCount() {
              
              return arr.size();
             }
            });
            
            
            
            
            
            
           }

           @Override
           public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
           }

          }


                  
                  <TextView
                      android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="電話(huà)"
                  android:id="@+id/tel"
                     
                      />
              </LinearLayout>
             

          </LinearLayout>

           

          ArrayAdapter方式
                                                                           //上下文對(duì)象    布局列表對(duì)象      顯示的TextView的ID   數(shù)組對(duì)象
            listView1.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.bianhao, new String[]{"選項(xiàng)一","選項(xiàng)二","選項(xiàng)三","選項(xiàng)四","選項(xiàng)五"}));


          SimpleAdapter方式

           listView1=(ListView) findViewById(R.id.listView1);
            
            ArrayList<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
            
            Map<String, Object> map1=new HashMap<String, Object>();
            map1.put("icon", R.drawable.ic1);
            map1.put("name", "功能一");
            list.add(map1);
            
            Map<String, Object> map2=new HashMap<String, Object>();
            map2.put("icon", R.drawable.ic2);
            map2.put("name", "功能二");
            list.add(map2);
            
            
            Map<String, Object> map3=new HashMap<String, Object>();
            map3.put("icon", R.drawable.ic3);
            map3.put("name", "功能三");
            list.add(map3);
            
            Map<String, Object> map4=new HashMap<String, Object>();
            map4.put("icon", R.drawable.ic1);
            map4.put("name", "功能四");
            list.add(map4);
            
            Map<String, Object> map5=new HashMap<String, Object>();
            map4.put("icon", R.drawable.ic5);
            map4.put("name", "功能五");
            list.add(map5);
            
            
            listView1.setAdapter(new SimpleAdapter(this, list, R.layout.list_item, new String[]{"icon","name"},new int[]{R.id.tubiao,R.id.gongneng} ));
            
            

            

          posted @ 2013-12-10 21:00 何云隆 閱讀(379) | 評(píng)論 (0)編輯 收藏

          利用AsyncHttpClient與服務(wù)器端傳輸數(shù)據(jù)

          創(chuàng)建一個(gè)顯示的界面xml
           <ListView
                  android:id="@+id/lv_show_view"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentTop="true"
                  android:layout_marginTop="16dp" >
              </ListView>

          再創(chuàng)建一個(gè)item.xml
          <?xml version="1.0" encoding="utf-8"?>
          <LinearLayout xmlns:android="    android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" >
             
           <TextView
               android:layout_width="250dip"
               android:layout_height="wrap_content"
               android:id="@+id/title"
              
              
               />
           <TextView
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:id="@+id/timelength"
              
              
               />
          </LinearLayout>


          導(dǎo)入AsyncHttpClient需要的類(lèi)

          之后


            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_show_list_activy);
            lv_show_view = (ListView) findViewById(R.id.lv_show_view);


             AsyncHttpClient client=new  AsyncHttpClient();
            
             String  url = "
               + "測(cè)試方法";
             client.get(url, new AsyncHttpResponseHandler() {
             
            
             public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
               List<Video> list=new ArrayList<Video>();
              try {
               Toast.makeText(ShowListActivy.this,statusCode+"", 1).show();
               
               String json = new String(responseBody);
                JSONArray array = new JSONArray(json);
               for(int i=0 ; i < array.length() ; i++){
                JSONObject item= array.getJSONObject(i);
               
                String id = item.getString("id");
                String title = item.getString("title");
                String timelength = item.getString("time");
                Log.e("jsonget", id+title+timelength);
                list.add(new Video( id, title, Integer.parseInt(timelength)));
               }
               List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
               for (Video v : list) {
                Map<String, Object> it = new HashMap<String, Object>();
                it.put("id", v.getId());
                it.put("title", v.getTitle());
                it.put("timelength", v.getTime());
                data.add(it);
               }
               SimpleAdapter adapter = new SimpleAdapter(ShowListActivy.this, data,R.layout.item, new String[] { "title", "timelength" },new int[] { R.id.title, R.id.timelength });
               lv_show_view.setAdapter(adapter);

               
               
               
              } catch ( Exception e) {
                Log.e("MainActivity", e.toString());
               
              }     
              
              
             }
             
            
             public void onFailure(int statusCode, Header[] headers,
               byte[] responseBody, Throwable error) {
              Toast.makeText(ShowListActivy.this,"shibai", 1).show();
              
             }
            });
            顯示出傳過(guò)來(lái)的json結(jié)果:
           
            
           

          本文章只是自己學(xué)習(xí)筆記,大家要慎重借鑒





          posted @ 2013-12-03 14:30 何云隆 閱讀(318) | 評(píng)論 (0)編輯 收藏

          文件下載到本地

          package com.shxt.controller;

          import java.io.File;
          import java.io.FileInputStream;
          import java.io.IOException;
          import java.io.OutputStream;
          import java.io.PrintWriter;
          import java.net.URLEncoder;

          import javax.servlet.ServletException;
          import javax.servlet.http.HttpServlet;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          public class DownLoadServlet extends HttpServlet {

           public void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {

            this.doPost(request, response);
           }

           public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {

            response.setContentType("application/x-msdownload");
            PrintWriter out = response.getWriter();
            response.reset();// 可以加也可以不加
            response.setContentType("application/x-download");
            String filedownload = request.getRealPath("/images")
              + "\\02_開(kāi)發(fā)第一個(gè)無(wú)狀態(tài)會(huì)話(huà)bean.avi";// "想辦法找到要提供下載的文件的物理路徑+文件名";
            System.out.print(filedownload);
            String filedisplay = "okokok.avi";// "給用戶(hù)提供的下載文件名";
            filedisplay = URLEncoder.encode(filedisplay, "UTF-8");
            response.addHeader("Content-Disposition", "attachment;filename="
              + filedisplay);
            

            OutputStream outp = null;
            FileInputStream in = null;
            try {
             outp = response.getOutputStream();
             // 你可以指定你的ftp輸入流
             in = new FileInputStream(new File(filedownload));

             byte[] b = new byte[1024];
             int i = 0;

             while ((i = in.read(b)) > 0) {
              outp.write(b, 0, i);
             }
             outp.flush();
            } catch (Exception e) {
             System.out.println("Error!");
             e.printStackTrace();
            } finally {
             if (in != null) {
              in.close();
              in = null;
             }
             if (outp != null) {
              outp.close();
              outp = null;
             }
             //out.clear();
             //out = pageContext.pushBody();
            }
           }

          }

          posted @ 2013-11-23 20:51 何云隆 閱讀(924) | 評(píng)論 (1)編輯 收藏

          ajax的傳值

               摘要: 轉(zhuǎn)自:轉(zhuǎn)載請(qǐng)標(biāo)明出處:http://blog.csdn.net/anyoneking/archive/2008/05/23/2472145.aspx1.回傳一個(gè)普通的String字符串.2.回傳一個(gè)組織好的Javascript字符串.3.回傳一個(gè)Json對(duì)象.(需要引入json.jar)4.回傳一個(gè)XML對(duì)象.基本實(shí)現(xiàn)如下:其中測(cè)試頁(yè)面為: <%@page language="j...  閱讀全文

          posted @ 2013-11-22 16:55 何云隆 閱讀(1846) | 評(píng)論 (2)編輯 收藏

          html錨點(diǎn)&jsp錨點(diǎn)

          經(jīng)過(guò)試驗(yàn)后發(fā)現(xiàn)HTML錨點(diǎn)在JSP中并不兼容。兩者表示錨點(diǎn)的方法有所不同

           

          HTML錨點(diǎn)

          <a href="#1">goto1</a>

          .

          .

          .

          .

          <a name="1">111</a>

          這樣從goto1可以定位到111

           

          JSP錨點(diǎn)

          <a href="javascript:void(0)" onclick="document.getElementById('1').scrollIntoView();">goto1</a>

          <a id="1">1111</a>

          posted @ 2013-09-18 16:49 何云隆 閱讀(319) | 評(píng)論 (0)編輯 收藏

          HTML to PDF

          HTML to PDF conversion for your website or application

          http://www.htm2pdf.co.uk/

          posted @ 2013-07-10 10:41 何云隆 閱讀(1396) | 評(píng)論 (1)編輯 收藏

          通過(guò)js事件獲取元素中的屬性值

          通過(guò)js事件獲取元素中的屬性值
          <div id="c-title1" onclick="openAndClose(this)" value="content1" >報(bào)告概覽</div>

            function openAndClose(myelement) {
             
              alert(myelement.attributes["value"].value );
              
              

            }

          posted @ 2013-05-29 21:42 何云隆 閱讀(851) | 評(píng)論 (1)編輯 收藏

          miniui超級(jí)強(qiáng)悍UI

          miniui超級(jí)強(qiáng)悍UI
          http://www.miniui.com/demo/#src=messagebox.html

          posted @ 2013-05-27 15:41 何云隆 閱讀(297) | 評(píng)論 (0)編輯 收藏

          js中動(dòng)態(tài)生成表格

          js中動(dòng)態(tài)生成表格
          function createTable() {
           var t = document.getElementById("myT");
           for ( var i = 0; i < 3; i++) {
            var r = t.insertRow();
            for ( var j = 0; j < 2; j++) {
             var c = r.insertCell();
             if (j == 0) {
              c.innerHTML = "姓名:"+i+","+j;
             } else {
              c.innerHTML = "<input type='text' name='n' />";
             }
            }
           }
           t.setAttribute('border', '1');
          }

          function deleteTable() {

           var objTable = document.getElementById("myT");
           objTable.setAttribute('border', '0');
           for ( var i = 0; i <= objTable.rows.length+1; i++) {
            objTable.deleteRow(0);

           }
           
          }




          jsp中的表單引發(fā)事件
          <input type="button" onclick="createTable()" name="ty" value="試題類(lèi)型" />
             &nbsp;
             <input type="button" onclick="deleteTable()" name="re" value="清除表格" />
             <table id="myT">
             
             </table>

          posted @ 2013-05-21 21:16 何云隆 閱讀(509) | 評(píng)論 (1)編輯 收藏

          JSTL獲取list的大小,jstl獲取list 的長(zhǎng)度,EL表達(dá)式獲取list的長(zhǎng)度,EL表達(dá)式獲取list大小

          JSTL獲取list的大小,jstl獲取list 的長(zhǎng)度,EL表達(dá)式獲取list的長(zhǎng)度,EL表達(dá)式獲取list大小 
          在jsp頁(yè)面中不能通過(guò)${list.size}取列表長(zhǎng)度,而是 
          <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
          <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
          <c:out value="${fn:length(list)}"></c:out> 

          posted @ 2013-04-20 16:58 何云隆 閱讀(4700) | 評(píng)論 (0)編輯 收藏

          Spring MVC使用動(dòng)態(tài)代理實(shí)現(xiàn)事務(wù)控制

          Spring MVC使用動(dòng)態(tài)代理實(shí)現(xiàn)事務(wù)控制
          applicationContext.xml文件中配置

          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
          xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
          xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
          xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
          http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
          http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
          default-lazy-init="true">
          <!--
          spring在啟動(dòng)的時(shí)候,會(huì)默認(rèn)加載會(huì)默認(rèn)加載整個(gè)對(duì)象實(shí)例圖,從初始化ACTION配置、到
          service配置到dao配置、乃至到數(shù)據(jù)庫(kù)連接、事務(wù)等等。這樣可以減少web服務(wù)器在運(yùn)行時(shí)的負(fù)擔(dān),但是對(duì)于開(kāi)發(fā)者來(lái)說(shuō)無(wú)疑是效率極低的一個(gè)設(shè)置了。
          還好,spring提供了default-lazy-init屬性,其配置形式如下,applicationContext.xml中: <
          beans default-lazy-init ="true" > < bean class ="org.xxxx.bean" >
          。。。。。。 </beans>
          spring配置默認(rèn)default-lazy-init為false,當(dāng)配置為true時(shí)sping不會(huì)再去加載整個(gè)對(duì)象實(shí)例圖,大大減少了初始化的時(shí)間,減少了spring的啟動(dòng)速度。
          這樣做只是為了在開(kāi)發(fā)過(guò)程中節(jié)約啟動(dòng)時(shí)間,在部署到實(shí)際環(huán)境中,倒是沒(méi)必要設(shè)置default-lazy-init為true。畢竟部署到實(shí)際環(huán)境中不是經(jīng)常的事,每次啟動(dòng)1分鐘倒不是大問(wèn)題,而且可以提高服務(wù)器效率。
          當(dāng)然,也不是所有的beans都能設(shè)置default-lazy-init成為true.對(duì)于scheduler的bean不能用lazy-init
          < beans default-lazy-init ="true" > < bean class
          ="org.springframework.scheduling.quartz.SchedulerFactoryBean" > <
          property name ="triggers" > < list > < ref bean ="buildHtmlTrigger" />
          < ref bean ="askTrigger" /> < ref bean ="mailSenderTrigger" /> < ref
          bean ="topicDetailBuildTrigger" /> < ref bean ="forumBuildTrigger" />
          < ref bean ="topicBuildTrigger" /> </ list > </ property > </ bean >
          </ beans > 這樣的話(huà)。所有的scheduler就都不管用了。所以請(qǐng)大家要注意。
          -->
           
          <!-- 使用annotation 自動(dòng)注冊(cè)bean, 并保證@Required、@Autowired的屬性被注入 -->
          <context:component-scan base-package="com.edufe">
          <context:exclude-filter type="annotation"
          expression="org.springframework.stereotype.Controller" />
          </context:component-scan>
          <context:property-placeholder
          ignore-resource-not-found="true"
          location="classpath*:/application.properties,
                     classpath*:/application.development.properties" />
          <!-- 創(chuàng)建數(shù)據(jù)源 -->
          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close">
          <property name="driverClassName" value="${jdbc.driver}" />
          <property name="url" value="${jdbc.url}" />
          <property name="username" value="${jdbc.username}" />
          <property name="password" value="${jdbc.password}" />
          </bean>
          <!-- 使用嵌入式數(shù)據(jù)庫(kù)H2 -->
          <!--
          <jdbc:embedded-database id="dataSource" type="H2"> <jdbc:script
          location="classpath:sql/h2/schema.sql" /> <jdbc:script
          location="classpath:sql/h2/import-data.sql" />
          </jdbc:embedded-database>
          -->
          <!-- 創(chuàng)建jdbcTemplate對(duì)象 -->
          <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
          <property name="dataSource" ref="dataSource" />
          </bean>
          <!-- 在容器文件中配置bean(service,dao,domain,action,數(shù)據(jù)源), -->
          <!--
          bean的作用是, 當(dāng)我們spring框架加載的時(shí)候,spring就會(huì)自動(dòng)創(chuàng)建一個(gè)bean,并放入內(nèi)存 即產(chǎn)生UserService
          user=new UserService(); user.setName("張三");
          -->
          <!--
          <bean id="userService" class=""> 這里就體現(xiàn)出了注入的概念 <property name="name">
          <value>張三</value> </property> 在UserService中引用ByeService的對(duì)象ref是個(gè)引用
          <property name="byeS" ref="byeService" /> </bean>
          -->
           
           
          <!-- 處理事務(wù) -->
          <!-- 生成一個(gè)事務(wù)管理對(duì)象 -->
          <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
          <constructor-arg index="0" ref="dataSource">
          </constructor-arg>
          </bean>
          <!-- 生成默認(rèn)事務(wù)定義對(duì)象 -->
          <bean id="def" class="org.springframework.transaction.support.DefaultTransactionDefinition"></bean>
           
          </beans>

          在dao中
          @Autowired
          private DataSourceTransactionManager transactionManager;
          @Autowired
          private DefaultTransactionDefinition def;
          public int excuteTrac() {
          int temp = 0;
          // 批插入
          String sql1[] = new String[4];
          // 向第一個(gè)表插入的語(yǔ)句
          sql1[0] = "insert into usermbo( ID, USERNAME, age) values('122','22','22')";
          sql1[1] = "insert into usermbo( ID, USERNAME, age) values('133','33','33')";
          sql1[2] = "insert into usermbo( ID, USERNAME, age) values('144','44','33')";
          sql1[3] = "insert into usermbo( ID, USERNAME, age) values('155','55','33')";
          String[] sql2 = new String[3];
          // 向第二個(gè)表插入的語(yǔ)句
          sql2[0] = "insert into address (NO, NAME) values('33','33')";
          // 此條數(shù)據(jù)是錯(cuò)誤數(shù)據(jù) 插入會(huì)出現(xiàn)異常
          sql2[1] = "insert into address (NO, NAME)  values('eee','44')";
          sql2[2] = "insert into address (NO, NAME)  values('144','44')";
           
          TransactionStatus status = transactionManager.getTransaction(def);
          try {
          int[] a = jdbcTemplate.batchUpdate(sql1);
          int[] b = jdbcTemplate.batchUpdate(sql2);
          try {
          transactionManager.commit(status);
          } catch (Exception e) {
          System.out.println("事務(wù)提交異常");
          }
          } catch (Exception ex) {
          System.out.println("出現(xiàn)事務(wù)異常");
          try {
          transactionManager.rollback(status);
          } catch (IllegalTransactionStateException e) {
          System.out.println("回滾數(shù)據(jù)異常");
          }
          temp = -1;
          }
          return temp;
          }

          posted @ 2013-04-19 10:56 何云隆 閱讀(6045) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 庐江县| 沁水县| 光山县| 祁连县| 乐业县| 望都县| 庆元县| 镇江市| 唐山市| 元朗区| 永福县| 梅州市| 郑州市| 伊通| 新兴县| 综艺| 茶陵县| 滦平县| 松滋市| 当雄县| 沂南县| 天峻县| 奈曼旗| 新田县| 新龙县| 苏尼特右旗| 鹿泉市| 沂源县| 旺苍县| 濮阳县| 汉源县| 驻马店市| 岐山县| 丁青县| 冕宁县| 衢州市| 锦州市| 邹平县| 车险| 西峡县| 彩票|