2013年12月3日
#
在SoapUI的Request URL中,每次輸入的URL中含有的大寫字母會自動轉換為小寫字母,導致請求不了,
這個問題在SoapUI 5.1.2和5.2.1版本中都存在,具體的解決辦法是在HTTP TestRequest Properties的屬性中,在Endpoint中輸入對應的含有大寫字母的URL即可。
Java使用網易郵箱服務器發送郵件實例
1 下載發送mail需要的jar包
activation.jar 與 mail.jar
2 創建 SendMail 類
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");//自己到網上查找網易發郵件的smtp服務地址 你的發件郵箱如果是163 你就查找163的發件服務器
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");
//第一個參數是發件服務器 第二個是你發件的郵箱名 第三個是你發件郵箱的密碼
transport.connect("smtp.263.net",”發件郵箱”,”發件郵箱密碼”);
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) {
//第一個參數 發件郵箱 第二個收件郵箱 第三個 郵件內容
new SendMail().send("yunlong090614@163.com", "1063342004@qq.com", "更改密碼校驗", "尊敬的用戶你好,您的校驗碼為:65432</br>xxxx");
}
<%@ 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}
安裝32位的Oracle客戶端( instantclient-basic-win32-11.2.0.1.0)。Win7 64位系統暫無PLSQLDeveloper,所以下一個32位的。
下載instantclient-basic-win32-11.2.0.1.0.zip (一定得是32位的,不要下錯了版本,Oracle官網有下載),將其解壓至Oracle安裝目錄的Product下(本機命名為:instantclient_11_2):D:\Oracle\app\Dell\product\instantclient_11_2
拷貝數據庫安裝根目錄下的一個文件夾:D:\Oracle\app\Dell\product\11.2.0\dbhome_1
\NETWORK到Oracle客戶端目錄下D:\Oracle\app\Dell\product\instantclient_11_2(其實只需要 NETWORK\ADMIN\tnsnames.ora)
修改oracle客戶端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)
) )
SELECT createDate,shortName,collNum,fullName FROM college
ORDER BY CONVERT( shortName USING gbk)
近幾日打印東西都是不成功,顯示不能發現打印機,處理方法如下:
啟動 print spooler服務 但是報1068錯誤,
在運行中輸入“sc config spooler depend= rpcss”,確定后,我再去啟用Print Spooler服務,居然成功了。我也不知道這是個什么命令,但是問題解決了,就要謝謝網絡上的高手們!
Java中的三元運算符為:條件?條件為true值:條件為false的值
EL也有一樣的運算符,用EL的三元運算符有時可以代替c:choose標簽,為我們的工作省下很大力氣。
比如gender為0顯示男,其余顯示女,我們可以這么寫:
<c:choose>
<c:when test="${gender eq 0}">男</c:when>
<c:otherwise>女</c:otherwise>
</c:choose>
但是不是顯得太麻煩了?其實我們這里就可以使用EL表達式中的三元運算符了,上面可以簡化為:
${gender eq 0?"男":"女"}
這樣是不是簡練了很多?在JSTL和EL處理非A即B的時候,三元運算符簡單了許多。
轉載請注明:觀測者 » JSP中EL表達式三元運算符的使用
jar -cvf safety.war *
打 war包命令
摘要: 引用地址http://www.cnblogs.com/xdp-gacl/p/3467245.html
用Jquery控制文本框只能輸入數字和字母
在公司開發WinForm項目時,發現公司自主研發的textbox控件非常強大,可以實現"只能輸入數字"、"只能輸入字母"和"只能輸入數字和字母"的三種輸入限制,這樣就可以精確控制用戶輸入的內容范圍,讓"用戶永遠沒有辦法輸入...
閱讀全文
SVN更新失敗,提示locked
- 瀏覽:3571
- |
- 更新:
打開eclipse彈出Error:could not open D:\java\lib\i386\jvm.cfg'
運行中 輸入regedit
沒有修改注冊表,解決辦法是:
重新安裝JDK時注冊表中\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environemt\1.6 項目下的JavaHome和RuntimeLib設置沒有更新,將這兩個項目更正即可.
分類: Java2012-07-23 09:46 1431人閱讀 收藏 舉報
最近在eclipse中開發android項目,用到了jquery mobile框架,則會涉及到新建html文件,發現eclipse不自帶新建html文件的插件,必須得新建一個其他形式的文件,譬如xml格式的文件,然后重命名,后綴名改成html,覺得這樣老麻煩的,所以在網上發現了Eclipse HTML Editor,不過此插件似乎只支持新建html文件,不支持其格式化。網上看了其他一個html格式化的插件Eclipse Tidy,不過用了后,發現格式化后的html一點都不符合代碼審讀標準。也不知道是不是自己哪邊沒設置好,還是本來就是那樣。
現在就暫先不管Eclipse Tidy了,看看如何安裝Eclipse HTML Editor。
1.下載GEF(依賴包):
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
只有一個tk.eclipse.plugin.htmleditor_2.1.0.jar文件
直接復制到eclipse\plugins里面
摘要: 基本資料:mysql> select version();+-----------+| version() |+-----------+| 5.0.16 |+-----------+ mysql> select * from t1;+----+------+| id | name |+----+------+| 1 | aa || 2 | bb || 3 | cc |+---...
閱讀全文
前言:之前做的ListView實現RadioButton的功能有bug,當ListView控件的內容超出屏幕可見區域時,滑動ListView控件會報錯,下面有為什么出錯和解決方法進行的注解,不多說了,看源碼,有更好的解決辦法請指教
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設為radioButton的id radioButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ //這段代碼來實現單選功能 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); } } }); //這里實現單選框選的回顯,解決了單選框移出屏幕范圍未選中狀態 if(temp == position){ radioButton.setChecked(true); } return convertView; } // Holder holder; // if(convertView == null){ //1,當第一次加載ListView控件時 convertView為空 // convertView = MainActivity.this.getLayoutInflater().inflate(R.layout.item, null); //所以當ListView控件沒有滑動時都會執行這條語句 // 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,因為這里對radioButton的id進行重新設置,滑動ListView時convertView不為空,上面的語句就沒法得到radioButton對象,這條語句就會報空指針異常 // 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="測試"> </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>
|
一,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="測試"> </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設為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(); } //這里實現單選框選的回顯,解決了單選框移出屏幕范圍未選中狀態 return convertView; } } } |
處理多個fragment之間replace刷新問題[轉]
每次創建fragment對象都會重新走onCreateView方法,所以多個fragment互相替換會重新刷新界面, 在application中創建一個View,保持onCreateVIew中創建的View 每次走onCreateView的時候判斷application中是否保持了View,如果為null,重新inflater走initView和initData方法,不為nul得到父類,移除子View,不然有父id無法再加入布局中, 以下是代碼: @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刷新問題 歡迎留言。 |
創建重復的背景圖片
在drawable目錄下創建一個repeat_bg.xml: src是引用圖片的名稱
1
2
3
4
5
6
7
8 |
1
<?xml version= "1.0" encoding= "utf-8" ?>
2
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>
|
通常情況下,SQL Server里面的生成SQL腳本,只會包含數據庫及表的字段結構,而不會包含表的數據,也就是SQL腳本里面只有Create database,Create table 這樣的語句,沒有insert into。
因為SQL Server并不包含這個功能,只能靠第三方的代碼了。
以下存儲過程可以實現:
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 -- 判斷對象是否存在
begin
print 'The object not exists'
return
end
set @objectname=rtrim(object_name(@objectId))
if @objectname is null or charindex(@objectname,@tablename)=0 --此判斷不嚴密
begin
print 'object not in current database'
return
end
if OBJECTPROPERTY(@objectId,'IsTable') < > 1 -- 判斷對象是否是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 暫時不處理
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
'+@tablenameprint
'--'+@sqlexec(@sql)
if @ident is not null
print 'SET IDENTITY_INSERT
'+@TableName+' OFF'
GO
使用方法:
exec UspOutputData 你的表名
選擇【執行模式】為“以文本顯示結果”,然后將運行后的結果存成.sql,加上用SQL Server生成的數據庫腳本就可以了。
另外可以利用第三方工具,導出數據可以用powerbuilder。在database painter里面,用SQL選出,或者直接打開表,點擊生成的list datawindow,然后在菜單file->save rows as->選擇SQL,那么生成的SQL語句就包括建表和insert數據的SQL了。
轉載:
http://blog.sina.com.cn/s/blog_49b531af0100i74v.html
前言
本章內容是android.widget.CompoundButton,翻譯來自德羅德,再次感謝德羅德 !期待你一起參與Android API 的中文翻譯,聯系我over140@gmail.com。
轉載
正文
一、結構
public abstract class CompoundButton extends Button implements Checkable
java.lang.Object
android.view.View android.widget.TextView android.widget.Button android.widget.CompoundButton
二、概述
一個帶有選中/未選中狀態的按鈕。當按鈕按下或點中時自動改變狀態。
三、公共方法
public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)
在子視圖的構建時分派一個輔助事件。(譯者注:通過源碼可以看出,視圖構建時設置其選中狀態。)
參數
event 事件
返回值
如果事件全部完成返回True。
public boolean isChecked ()
(譯者注:是否選中)
public void onRestoreInstanceState (Parcelable state)
允許視圖重新應用以前通過onSaveInstanceState()生成代表內部的狀態。這個函數決不調用一個空的狀態。
參數
state 返回以前調用onSaveInstanceState()保存下來的狀態。
public Parcelable onSaveInstanceState ()
允許視圖生成一個代表內部的狀態,以后可用于創建一個與之相同的新的實例。這種狀態應該只包含非持久或以后不能夠重建的信息。例如,你決不存儲你當前在屏幕上的位置,因為這會在視圖的層面上重新計算放置一個新的實例。
你可以存儲到這里的一些例子:一個文本框中當前光標的位置(但通常不是文字本身,文字通常保存在內容提供者(content provider)或其他持久的儲存中),一個列表視圖中的當前選中項。
返回值
返回一個包含視圖當前狀態的Parcelable對象,或沒有什么狀態保存時返回null。默認實現返回null。
public boolean performClick ()
如果視圖定義了OnClickListener監聽器,調用此方法來執行。
返回值
定義了的OnClickListener被調用返回True,否則返回False
public void setButtonDrawable (Drawable d)
給按鈕背景設置一個可繪制對象(如:圖像)
參數
d 用作背景的可繪制對象(如:圖像)
public void setButtonDrawable (int resid)
通過資源Id給按鈕背景設置一個圖像
參數
resid 作為背景圖像的資源id
public void setChecked (boolean checked)
改變按鈕的選中狀態
參數
checked true選中,false非選中
public void setOnCheckedChangeListener (CompoundButton.OnCheckedChangeListener listener)
注冊一個在按鈕狀態發生改變時執行的回調函數
參數
listener 當選中狀態改變時調用的函數
public void toggle ()
改變選中狀態為當前狀態的逆狀態
四、受保護方法
protected void drawableStateChanged ()
在視圖狀態的變化影響到所顯示可繪制的狀態時調用這個方法。
確保在重載時中調用父類方法
protected int[] onCreateDrawableState (int extraSpace)
為當前視圖生成新的可繪圖區狀態。這個方式當緩存的圖像繪圖區狀態確定失效時通過視圖系統調用。你可以使用getDrawableState()方法重新取得當前的狀態。
參數
extraSpace 如果為非零,這是你應該返回的數組在你可以存放你的狀態的額外條目的數量。
返回值
返回一個記錄著視圖中當前繪圖區狀態的數組
protected void onDraw (Canvas canvas)
實現你自己的繪制。
參數
canvas 在畫布上繪制背景
protected boolean verifyDrawable (Drawable who)
如果你的視圖子類顯示他自己的可視化對象,他將要重寫此方法并且為了顯示可繪制返回true。此操作允許進行繪制時有動畫效果。
確認當重寫從方法時,需調用父類相應方法。
參數
who 需判斷的可繪制對象(Drawable)。如果是你要顯示的對象,返回True,否則返回調用父類的結果。
返回值
boolean 如果可繪制對象(Drawable)已經在視圖中顯示,返回True否則返回false。并且此處不允許使用動畫。
別人覺得你是不是在打工,這個不重要。重要的是你自己千萬別把自己當成打工的,換個角度去看,是公司給你發工資,替你交學費,練著你自己的能力和經驗。你遇到產品經理、技術高手,或者公司創始人,從他們身上學到成功的經驗,甚至是失敗的教訓。

我覺得有的人對創業的理解有誤區。他們把創業理解成幾個哥們開一個公司,回去印幾盒名片,我叫董事局主-席,你叫首席執行官,自己的同學脖子上都掛上個CXO,名字很洋氣,也不知道什么意思。如果把這個理解為創業就大錯特錯。
我希望大家這樣來理解創業,把創業看成是一種心態,為了實現一個目標,孜孜不倦的去追求。只要你不滿足于現狀,想法設法去突破,那就是創業。如果你是一個在校學生,是搞電腦,如果你不滿足于只是把學分學好,不滿足于把考試應付好,而是花了很多時間提高你的編程能力,下了很大功夫來研究很多軟件,那這也是創業。學習是這樣,工作也是這樣,只要你勇敢的正視問題,積極的去解決問題,敢于去承擔未來的風險,這其實就是創業心態。
如果我們把創業都理解成我今天出去成立一個公司,明天上市,后天市值超越Facebook,對不起,從來沒有過這樣成功的例子。天底下哪里有這么一帆風順的事?把你放在一馬平川的大平原上,你憑著直覺沿著直線走,其實從高空看下去,你走出來的路是彎的,是曲折的。創業也是一樣,雖然心里有個目標,但是要達到那個目標,你得解決一個個實際的問題。人的路都是一步一步走出來的,而且這個路一定不是直線。
在中國更是這樣,環境確實太復雜了。特別是在創業早期,你沒有經驗,沒有資源,你頭腦里的創新可能僅僅就是一個想法,一個主意,但如果實現不了,那它就什么都不是。但是,要實現這個想法,這個主意,你需要有判斷力,需要有經驗,需要有知識。所以,我一直提倡大學生剛畢業的時候,不要頭腦一熱就攢出一個公司來,最好的方法是加入一家創業公司,甚至可以加入風險很大的種子公司,去學習創業,感受創業。
很多人說,我加入別人的公司,那我不就成了一個打工的了嗎?給別人打工,誰認真干呀。錯了,如果你覺得自己是打工的,那你一輩子都是打工的。別人覺得你是不是在打工,這個不重要。重要的是你自己千萬別把自己當成打工的,換個角度去看,是公司給你發工資,替你交學費,練著你自己的能力和經驗。你遇到產品經理、技術高手,或者公司創始人,從他們身上學到成功的經驗,甚至是失敗的教訓。
如果你加入這個公司,這個公司兩年之后死了,恭喜你,你一分錢沒損失,你參與一個活生生的公司從生到死的例子,你以后就可以避免重蹈覆轍。你一分錢沒花,你讓一個公司死了一回,你學到了如何避免失敗的教訓,這是一個多么值的事。這比你拿多少工資,比你到一個有名的大公司,有用多了。
別人一見你,都說你在北京某大公司工作,太了不起。那都是虛榮心,一點意義沒有。所以我一直強調,如果你懷著創業的心態,那么你在什么狀態都可以叫創業。等到有一天,當你有一股強烈的沖動要辦公司去創業的時候,有可能你會發現,人各有所長,你不一定是做CEO的料,但你可能是優秀的CTO,你可能是很好的銷售主管,這個時候你就知道找什么樣的合伙人去創業了。
所以,我鼓勵大家創業,其實是鼓勵大家培養創業的精神,我不主張各位一定要出去成立一個公司,那只是一個形式。美國硅谷很多人不是先裝模作樣地成立一個公司,而是在家里的車庫,利用業余時間先搞出來一個產品,這也是創業的一部分。
我不希望傳授什么成功學,我最希望大家能夠想清楚未來幾年自己心里想要什么。在你創業的時候,不論遇到誘惑還是遇到挑戰,都能夠記住我說的那句話:拒絕平庸,與眾不同。你不一定要追隨當時的主流,也要能耐得住寂寞,甚至要有一種韌性,敢于屢敗屢戰,在未來長達五年或者八年、十年的時間里一直堅韌不拔地去探索,我相信五年以后、十年以后,可能中國新一代的企業家,中國新一代的創新領袖應該從各位里面誕生。
android library projects cannot be launched
properties 在android選項中將 is library中將前面的勾去了
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="編號"
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("編號:"+i);
a.add("姓名:"+i);
a.add("電話:"+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, "測試創建對象位置:"+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="電話"
android:id="@+id/tel"
/>
</LinearLayout>
</LinearLayout>

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

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} ));
創建一個顯示的界面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>
再創建一個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>
導入AsyncHttpClient需要的類

之后
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 = " + "測試方法";
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();
}
});
顯示出傳過來的json結果:

本文章只是自己學習筆記,大家要慎重借鑒