欧美自拍小视频_国产片在线免费观看_中文字幕啪啪_成人av高清在线_欧美一区二区视频免费观看_亚洲国产激情


曙海教育集團(tuán)論壇3G手機(jī)技術(shù)專(zhuān)區(qū)Android應(yīng)用開(kāi)發(fā) → Widget開(kāi)發(fā)入門(mén)-Android平臺(tái)


  共有8529人關(guān)注過(guò)本帖樹(shù)形打印

主題:Widget開(kāi)發(fā)入門(mén)-Android平臺(tái)

美女呀,離線(xiàn),留言給我吧!
wangxinxin
  1樓 個(gè)性首頁(yè) | 博客 | 信息 | 搜索 | 郵箱 | 主頁(yè) | UC


加好友 發(fā)短信
等級(jí):青蜂俠 帖子:1393 積分:14038 威望:0 精華:0 注冊(cè):2010-11-12 11:08:23
Widget開(kāi)發(fā)入門(mén)-Android平臺(tái)  發(fā)帖心情 Post By:2010-12-3 12:53:07

本例是為了實(shí)現(xiàn)一個(gè)手機(jī)Android平臺(tái)的Widget,該Widget中的內(nèi)容是根據(jù)輸入賬號(hào)從嘰歪網(wǎng)站上獲得得。當(dāng)然,這個(gè)過(guò)程需要嘰歪的API,得到信息后進(jìn)行處理并顯示出來(lái)。大體流程就是這樣。好了,進(jìn)入第一步。

該嘰歪賬號(hào)是測(cè)試賬號(hào),用戶(hù)名是“students”,密碼是“111111” 請(qǐng)不要擅自更改。

2. 建立一個(gè)Widget
Android reference中有關(guān)于如何建立一個(gè)Widget的詳細(xì)方法,這里簡(jiǎn)要說(shuō)明一下,詳情可以查看Android SDK中自帶的reference。

要建立一個(gè)Widget,分為如下幾個(gè)步驟:
(1) 創(chuàng)建一個(gè)類(lèi),讓其繼承類(lèi)AppWidgetProvider,在AppWidgetProvider中有許多方法,例如onDelete(Context,int[]),onEnable(Context)等,但一般情況下我們只是覆寫(xiě)onUpdate(Context,AppWidgetManager,int[])方法。在該方法中,我們啟動(dòng)后臺(tái)服務(wù)的類(lèi),一般是啟動(dòng)Thread類(lèi)或者Android中的Service類(lèi)。在該類(lèi)中我們進(jìn)行從服務(wù)器端獲得數(shù)據(jù)并進(jìn)行處理并在Widget中顯示。

(2) 在你的AndroidMenifest.xml中添加一個(gè)receiver標(biāo)簽,讓其指向你的AppWidgetProvider子類(lèi)。內(nèi)容如下:
<receiver android:name="JiwaiWidget"
android:label="@string/app_name"
android:icon="@drawable/jiwai">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
            android:resource="@xml/info" />
</receiver>
對(duì)上面的代碼進(jìn)行解釋?zhuān)?
第一行指定該Widget的接收者是JiwaiWidget,即你建立的AppWidgetProvider子類(lèi);
第二行指定該Widget的標(biāo)簽名稱(chēng),值為value目錄下string.xml中的app_name值;
第三行指定該Widget的圖標(biāo),值為drawable目錄下jiwai圖片;
第四行-第六行是采用Android文檔中提供的;
第七行指定該Widget的描述者信息,該描述著中定義了Widget的相關(guān)信息,如該Widget的寬度、長(zhǎng)度、自動(dòng)更新的間隔時(shí)間等信息,該描述位于xml目錄下的info.xml中。

(3) 編寫(xiě)你的Widget的provider文件信息(本例中是xml/info.xml)
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="200dp"
    android:minHeight="90dp"
    android:updatePeriodMillis="43200000"
    android:initialLayout="@layout/appwidget"
    android:c>
</appwidget-provider>
其中android:updatePeriodMillis是自動(dòng)更新的時(shí)間間隔,android:initialLayout是Widget的界面描述文件。Android:configure是可選的,如果你的Widget需要在啟動(dòng)時(shí)先啟動(dòng)一個(gè)Activity,則需要設(shè)定該項(xiàng)為你的Activity。本例中,需要你的嘀咕帳號(hào)和密碼,所以應(yīng)先顯示一個(gè)Activity,輸入你的賬號(hào)和密碼,然后將得到的信息在你的Widget中顯示。

(4) 在layout目錄下編寫(xiě)appwidget.xml文件,配置你的Widget的界面信息:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android圖片點(diǎn)擊可在新窗口打開(kāi)查看rientation="vertical"
android:id="@+id/widget"
android:background="@drawable/title_a">
<LinearLayout android:layout_width="fill_parent"
android圖片點(diǎn)擊可在新窗口打開(kāi)查看rientation="horizontal"
android:layout_height="wrap_content"
android:background="@drawable/title">
<TextView android:id="@+id/username_display"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#ffffff"
android:textSize="15px"
android:gravity="left|center_vertical"
android:paddingLeft="6px" />
</LinearLayout>

<LinearLayout android圖片點(diǎn)擊可在新窗口打開(kāi)查看rientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView android:id="@+id/text1"
android:layout_width="fill_parent"
android:textColor="#ffffff"
android:textSize="12px"
android:gravity="center_vertical|left"
android:paddingLeft="6px"
android:layout_height="30px">
</TextView>

<TextView android:id="@+id/text2"
android:textColor="#ffffff"
android:layout_height="30px"
android:gravity="center_vertical|left"
android:textSize="12px"
android:paddingLeft="6px"
android:layout_width="fill_parent">
</TextView>
</LinearLayout>
</LinearLayout>


該Widget中包括三個(gè)Textview,兩個(gè)用來(lái)顯示嘰歪的信息,一個(gè)用來(lái)顯示用戶(hù)名,上述代碼比較簡(jiǎn)單,故不做解釋。

(5) 由于需要一個(gè)Acvivity對(duì)象用來(lái)輸入賬戶(hù)信息,所以在layout目錄下新建一個(gè)login.xml,作為Activity的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android圖片點(diǎn)擊可在新窗口打開(kāi)查看rientation="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"
android:textColor="#ff8c00"
android:capitalize="characters"
android:textStyle="bold" />

<LinearLayout android圖片點(diǎn)擊可在新窗口打開(kāi)查看rientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">

<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user"
android:textColor="#ff8cff"
android:capitalize="characters" />

<EditText android:id="@+id/username"
android:layout_width="200px"
android:layout_height="wrap_content" />

</LinearLayout>

<LinearLayout android圖片點(diǎn)擊可在新窗口打開(kāi)查看rientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">

<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/code"
android:textColor="#ff8cff"
android:capitalize="characters" />

<EditText android:id="@+id/password"
android:layout_width="200px"
android:layout_height="wrap_content"
android:password="true" />
</LinearLayout>

<LinearLayout android圖片點(diǎn)擊可在新窗口打開(kāi)查看rientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">

<Button
    android:id="@+id/submit"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Submit"   
    />
</LinearLayout>
</LinearLayout>
有兩個(gè)EditText用來(lái)輸入用戶(hù)名和密碼,另外還有一個(gè)Button對(duì)象。

支持(0中立(0反對(duì)(0單帖管理 | 引用 | 回復(fù) 回到頂部

返回版面帖子列表

Widget開(kāi)發(fā)入門(mén)-Android平臺(tái)








簽名
主站蜘蛛池模板: 久久国产视频一区 | 中文字幕人妻偷伦在线视频 | 国产精品麻豆久久久 | 高清精品一区二区三区一区 | 欧美人人干 | 国产午夜激无码av毛片 | 久久亚洲精品中文字幕二区 | 一级a毛片免费观看 | 99视频精品全国在线观看 | 国产高清a毛片在线看 | 97久久精品人妻人人搡人人玩 | 欧美综合天天夜夜久久 | 欧洲成人在线观看 | 国产丝袜视频一区二区三区 | 欧美俄罗斯乱妇 | 日本一级片在线 | 在线精品无码字幕无码av | 免费人成在线观看视频播放 | 国产成人无码a区在线 | 日韩一区二区三区在线观看 | 看全色黄大色黄大片毛片 | 国产精品无码一区二区在线 | 精品亚洲一区二区三区在线观看 | 91在线视频观看 | 视频成人永久免费看 | 亚洲av无码久久精品色欲 | 麻豆精品人妻一区二区三区蜜桃 | a级国产 | 中国老太婆bb无套内射 | 午夜啪啪网 | 美女张开腿让男生桶出水 | 国产偷人视频 | 日本丰满熟妇videossex | 99久久精品自在自看国产 | 亚洲爆乳无码一区二区三区 | vr成人片在线播放网站 | 精品综合久久久久久88小说 | 成人免费观看男女羞羞视频 | 久久久久99精品成人片 | 西西大胆午夜人体视频 | 人妻无码久久久久久久久久久 |