天天看點

android之路,helloworld簡單控件的使用

<b>第一個andriod</b><b>程式,helloworld</b>

<b>建立andriod</b><b>工程 file ----</b><b>ànew-----</b><b>àandriod application project</b>

android之路,helloworld簡單控件的使用

<b></b>

<b>輸入application name </b><b>“Helloworld</b><b>”</b>

<b>Project</b>

name <b>會自己随着application name </b><b>填充</b>

<b>Package</b>

name    “.com.wj.Helloworld”

<b>Minimum</b>

required sdk <b>選擇andriod</b><b>版本号</b>

<b> </b>

<b>進入工程,選中工程名字,右鍵“run as</b><b>”---</b><b>à </b><b>“android application</b><b>”</b>

android之路,helloworld簡單控件的使用

<b>解決方案:</b>

android之路,helloworld簡單控件的使用

<b>eclipse</b><b>中右鍵這個檔案</b><b>---&gt;Build Path--&gt; remove it from build path</b>

<b>程式分析:</b>

android之路,helloworld簡單控件的使用
android之路,helloworld簡單控件的使用

<b>MainActivity</b><b>類,內建Activity</b><b>,每一個Acitvity</b><b>對象是一個單獨是實體,在應用程式中有多個Activity</b><b>,但是每次隻能有一個展現在使用者面前。</b>

<b>onCreate</b><b>()會在Activity</b><b>運作時被andriod</b><b>調用,是以在這裡需要進行初始化操作。</b>

<b>setContentView() </b><b>讀取資源檔案“R.layout.activity_main</b><b>”,系統自己解析檔案</b>

android之路,helloworld簡單控件的使用

<b>Assets</b><b>檔案夾,放置比較大的資源檔案,程式将資源全部打包</b>

android之路,helloworld簡單控件的使用

<b>Res</b><b>檔案夾 </b><b>放置小的資源檔案,程式隻打包使用的資源</b>

<b>Layout</b><b>檔案夾 </b><b>放置布局檔案</b>

<b>Menu </b><b>菜單檔案夾</b>

<b>Value </b><b>字元串檔案夾</b>

<b>                                                 TextView</b><b>控件</b>

<b>TextView:</b><b>不可編輯的控件,建立方法:</b>

<b>在activity_main.xml</b><b>檔案中建立,(推薦方法)</b>

android之路,helloworld簡單控件的使用

<b>在Mainactivity.java</b><b>中建立</b>

android之路,helloworld簡單控件的使用

<b>Android</b><b>:autolink</b><b>設定超鍊,有此屬性就可以設定電話号碼或者網址等成為超連結</b>

<b>       Autolink </b><b>的屬性:   none</b><b>無,web</b><b>網址超連結, mail</b><b>郵件超連結</b>

<b>                         Phone </b><b>電話号碼超連結  map</b><b>地圖超連結 all</b><b>以上全部都是</b>

android之路,helloworld簡單控件的使用
android之路,helloworld簡單控件的使用

<b>Android</b><b>:singleline </b><b>字在一行顯示</b>

<b>    Singleline </b><b>的屬性設定為true</b><b>,那麼字型就在一行顯示</b>

<b>Android</b><b>:ellipsize </b><b>設定省略号</b>

<b>       </b><b>當字全部在一行顯示的時候,可以設定省略号,start</b><b>省略号在開頭,end</b><b>省略号在結尾,middle</b><b>省略号在中間,</b>

android之路,helloworld簡單控件的使用

<b>Android</b><b>:marqueeRepeatLinit</b>

<b>       </b><b>其屬性設定為marquee_forever</b><b>,這樣就會實作文字滾動顯示,前提是文字必須設定為在同一行顯示</b>

<b>                                                           EditText</b><b>控件                     </b>

<b>TextEdit</b><b>控件可以編輯,預設的滑鼠會聚焦在行首,而且光标會閃爍</b>

<b>建立控件</b>

<b><b>EditText</b><b></b></b>

<b>    android:layout_width="fill_parent"           </b><b>填充父容器</b><b></b>

<b>    android:layout_height="wrap_content"         </b><b>包裹内容</b><b></b>

<b>    android:maxLength="5"                          </b><b>設定最大輸入字元數</b><b></b>

<b>        android:inputType="number"                    </b><b>設定輸入的字元類型</b><b></b>

<b>        android:hint="</b><b>我是</b><b>edit"                         </b><b>提示字元</b><b></b>

<b>        android:drawableLeft="@drawable/ic_launcher"  </b><b>插入圖檔</b><b></b>

<b>    /&gt;</b>

android之路,helloworld簡單控件的使用

繼續閱讀