當前位置:首頁 » 安卓系統 » androidloginto

androidloginto

發布時間: 2025-10-14 21:47:06

㈠ android開發支付寶付款實時通知是怎麼實現的

到支付寶官網,下載支付寶集成開發包,看懂裡面的關鍵代碼

由於android設備一般用的都是無線支付,所有我們申請的就是支付寶無線快捷支付介面。


如果鏈接失效,你可以到支付寶官網商家服務模塊中找到 快捷支付(無線)這個服務。

下載集成開發包,解壓發現裡面有客戶端的demo即說明文檔,在客戶端的demo中找到Android_SDK,這個就是你要用到的支付寶介面及demo。


把demo(alipay_sdk_demo)和(alipay_lib)導入到你的eclipse裡面,然後你可以試著運行一遍demo(alipay_sdk_demo),只要把這個demo搞懂了,你就會調用這個支付寶介面了。至於到時候如何集成到你的項目裡面,文檔上說明很詳細,按著文檔上一步一步來就行了。我的建議是先把這個demo弄懂再設計你的項目,看看調用介面時需要哪些數據,這樣也有利於你一開始設計數據。

下面來簡單的介紹下介面demo裡面的結構。

你打開項目會發現裡面有5個類。

java">kagecom.alipay.android.msp.demo;

importjava.io.IOException;
........
........
importcom.alipay.android.app.sdk.AliPay;

,
OnClickListener{
publicstaticfinalStringTAG="alipay-sdk";

privatestaticfinalintRQF_PAY=1;

privatestaticfinalintRQF_LOGIN=2;

privateEditTextmUserId;
privateButtonmLogon;

@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.external_partner);

initProcts();
initListView();
}

/*
*(non-Javadoc)
*
*@seeandroid.app.Activity#onCreateOptionsMenu(android.view.Menu)
*/
@Override
(Menumenu){
menu.add(Menu.NONE,Menu.FIRST,1,"快速登錄");
returntrue;
}

/*
*(non-Javadoc)
*
*@seeandroid.app.Activity#onOptionsItemSelected(android.view.MenuItem)
*/
@Override
(MenuItemitem){
switch(item.getItemId()){
caseMenu.FIRST:
setContentView(R.layout.trustlogin);
mUserId=(EditText)findViewById(R.id.user_id);
mLogon=(Button)findViewById(R.id.get_token);
mLogon.setOnClickListener(this);
break;
}
returnfalse;
}

privatevoidinitProcts(){
if(sProcts!=null)
return;

XmlResourceParserparser=getResources().getXml(R.xml.procts);
ArrayList<Proct>procts=newArrayList<Proct>();
Proctproct=null;

try{
inteventType=parser.getEventType();

while(eventType!=XmlPullParser.END_DOCUMENT){
if(eventType==XmlPullParser.START_TAG
&&parser.getName().equalsIgnoreCase("proct")){
proct=newProct();
proct.subject=parser.getAttributeValue(0);
proct.body=parser.getAttributeValue(1);
proct.price=parser.getAttributeValue(2);
procts.add(proct);
}
eventType=parser.next();
}

sProcts=newProct[procts.size()];
procts.toArray(sProcts);

}catch(XmlPullParserExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}
}
//listview點擊事件,裡面調用的支付寶介面
@Override
publicvoidonItemClick(AdapterView<?>arg0,Viewarg1,intposition,
longarg3){
try{
Log.i("ExternalPartner","onItemClick");
Stringinfo=getNewOrderInfo(position);//這個是訂單信息
Stringsign=Rsa.sign(info,Keys.PRIVATE);//簽名加密訂單信息什麼的
sign=URLEncoder.encode(sign);
info+="&sign=""+sign+""&"+getSignType();
Log.i("ExternalPartner","startpay");
//startthepay.
Log.i(TAG,"info="+info);

finalStringorderInfo=info;
newThread(){
publicvoidrun(){
AliPayalipay=newAliPay(ExternalPartner.this,mHandler);//這個應該就是支付寶介面了,哈哈,支付寶現在把很多功能都封裝了,所以省了很多代碼

//設置為沙箱模式,不設置默認為線上環境
//alipay.setSandBox(true);

Stringresult=alipay.pay(orderInfo);//這個是返回的結果,你到時候可以根據這個結果加以操作你想操作的,然後基本就完了,其他的你想附加的功能你看著寫吧,現在Key.java配置好就能調用快捷支付了
//後面的這些代碼可以改成你自己的,也可以在它們的基礎上改
Log.i(TAG,"result="+result);
Messagemsg=newMessage();
msg.what=RQF_PAY;
msg.obj=result;
mHandler.sendMessage(msg);
}
}.start();

}catch(Exceptionex){
ex.printStackTrace();
Toast.makeText(ExternalPartner.this,R.string.remote_call_failed,
Toast.LENGTH_SHORT).show();
}
}
//獲得訂單信息的方法
privateStringgetNewOrderInfo(intposition){
StringBuildersb=newStringBuilder();
sb.append("partner="");
sb.append(Keys.DEFAULT_PARTNER);//合作身份者id
sb.append(""&out_trade_no="");
sb.append(getOutTradeNo());//這個是訂單編號
sb.append(""&subject="");
sb.append(sProcts[position].subject);//這個應該是商品名稱
sb.append(""&body="");
sb.append(sProcts[position].body);//這個應該是商品的描述,具體你可以參考demo
sb.append(""&total_fee="");
sb.append(sProcts[position].price.replace("一口價:",""));//這個是要付款的金額,到時候你調用的時候改下就行了
sb.append(""¬ify_url="");
//網址需要做URL編碼
sb.append(URLEncoder.encode("http://notify.java.jpxx.org/index.jsp"));//伺服器非同步通知頁面,完成交易後通知商家伺服器的頁面,以post的形式將商品訂單信息發送到指定頁面,手機客戶端不需要可以先放在這不管。是不是,這個類很簡單看懂吧,就一listview。調用支付寶介面的方法就在onItemClick()方法裡面,如果你是一個按鈕的話換成按鈕點擊事件就行了,主要的細節我注釋已寫。現在你要想的是,需要哪些數據,提供給onItemClick()方法裡面的Stringinfo。demo裡面的數據是getNewOrderInfo(intposition)這個方法提供的,你可以自己提供或者在上面修改下。
現在,你已經知道代碼是如何調用支付寶介面了。接下來,是如何把這些集成到你的項目中去。

㈡ 用別人的android代碼怎麼修改

1、可以使用 eclipse 來編輯 JAVA 程序、檢查錯誤(主要是類庫包含和語法方面),但是不能在 eclipse 上編譯運行 android 源碼,還是得在 shell 中 make(或 mm 或 mmm)
2、android 源碼文件夾里提供有一些 eclipse 配置文件, .claapath:eclipse 工程的配置文件,方便我們直接把 android 源碼相應的文件和 JAVA 包導入工程 android-formatting.xml 和 android.importorder:這個很重要,主要是用來規范我們的編碼風格,更容 易使我們的代碼風格一致
3、把 android 源碼作為一個工程導入 eclipse 時,必須注意兩點
1)、新建的工程必須是 java project,不能是 android project,否則會破壞 android 源碼(一般是多添 加文件/文件夾)
2)、導入前最好檢查.classpath 里的文件在 android 源碼中是否有相應的文件(文件夾),否則也會破壞 android 源碼(一般是多添加文件/文件夾)
總的來說: 1、用 eclipse 來編輯代碼、檢查錯誤
2、不在 eclipse 上編譯、運行 android 源碼程序,只能在命令行通過 make(或 mm 或 mmm)編譯 android 源 碼
3、可以在 eclipse 上調試 android 源碼程序(原理:eclipse 通過 ddms 伺服器在 emulator 上進行調試), 並可以單步調試、斷點調試。
下面,從官方文檔總結出具體怎樣用 eclipse 來開發 android 源碼
1、建立基本的 android 開發環境 請參考官方文檔或<android 模擬器在 ubuntu8.10 的安裝> 2、編譯 android 源碼 android 源碼根目錄下通過 make 進行編譯,請注意一些配置,具體可參考<android 源碼的編譯>
3、把 eclipse 工程配置文件復制到 android 源碼根目錄下 cp development/ide/eclipse/.classpath ./ chmod u+w .classpath # Make the writable
4、修改 eclipse 程序的配置 1)、修改 eclipse 緩存設置 把 eclipse.ini(在 eclipse 軟體的安裝目錄下)的 3 個值改為下面的值: -Xms128m -Xmx512m -XX:MaxPermSize=256m 2)、把 android-formatting.xml 和 android.importorder 導入 eclipse android-formatting.xml、.classpath 和 android.importorder 都放在 development/ide/eclipse/下 android-formatting.xml 用來配置 eclipse 編輯器的代碼風格;android.importorder 用來配置 eclipse 的 import 的順序和結構。 在 window->preferences->java->Code style->Formatter 中導入 android-formatting.xml 在 window->preferences->java->Code style->Organize Imports 中導入 android.importorder 3)、安裝 anyedit 插件(可選) 在 http://andrei.gmxhome.de/anyedit/下載並導入 eclipse 中
5、把 android 源碼作為一個工程導入 eclipse 導入前先檢查.classpath 里的文件在 android 源碼中是否有相應的文件 (文件夾) 否則也會破壞 android , 源碼(一般是多添加文件/文件夾),.classpath 里多餘的路徑可刪除 新建 Java Project(不是 android project,否則會破壞 android 源碼),選擇從已存在的工程導入,工 程名任意,完成。 導入時,eclipse 要 build 工程,比較慢。導完後,一般都沒有錯誤。
6、eclipse 上調試 android 里的程序。 先執行: cd android 源碼目錄 . build/envsetup.sh lunch 1 emulator & ddms & # to build the emulator # you should see a GUI picture of a phone # you should get a splufty debugging console 然後在 eclipse 中配置調試類型和埠: 在 Run->Debug Configurations->Remote java application 上雙擊,然後,」Host:」設為 localhost,」 Port:」設為 8700,」Connection Type」為 Standard(Socket Attach) 然後「Apply」 注意,在點擊」Debug」時苦出錯,說 8700 埠被佔用,那麼把 DDMS 程序關掉,重新打開 DDMS 就 OK 了。 如果提供連不到 VM 錯誤時,請注意,要先在 DDMS 中選中某一進程(對應某一應用程序),才能在 eclipse 執行 Debug。 在 eclipse 調試時,可以設斷點、單步調試。估計 google 團隊也是這樣開發、調試 android 應用程序的
7、編譯 android 源碼 執行: cd android 源碼目錄 . build/envsetup.sh 那麼就會多出 mm/mmm 等命令, mm/mmm 用來編譯模塊 (包括 C、 C++、 JAVA 程序)我們也可以直接在 android 。 源碼根目錄下執行「make 模塊名」來編譯模塊。 Android 源碼中添加 修改應用 Posted on 2010-08-19 13:37 zhangweia 閱讀(1607) 評論(0) 編輯 收藏 第一部分:添加一個新的應用 1. 在和系統相同版本的 SDK 目錄下開發自己的 android 應用 2. 把開發的 android 工程放到源碼的 packages/apps/目錄下 3. 在工程目錄下添加 Android.mk 文件,修改 LOCAL_PACKAGE_NAME :=test001 把工程名指定為 自己的工程名,我載入的工程為 test001 LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := user LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := googlelogin-client LOCAL_PACKAGE_NAME :=test001 LOCAL_CERTIFICATE := shared include $(BUILD_PACKAGE) # Use the folloing include to make our test apk. include $(call all-makefiles-under,$(LOCAL_PATH)) 4. 回到源碼目錄,然後執行 . build/envsetup.sh 注意 sh 後面有個空格 5. 執行 mmm packages/apps/test001 編譯 test001.apk 包 6. 執行 make snod,編譯 system.img 包 7. 執行 emulator &就可以在應用程序下看到自己編譯的工程了 第二部分:修改原有的 Android 應用 1. 首先新建一個 android 工程,載入自己的 java 文件和資源文件 2. 在自己的 android 工程初步調試成功以後,把該工程的 java 文件,資源文件拷貝到聯系人對應的 java 文件和資源文件目錄 3. 然後在 linux 下執行以下命令,編譯人聯系人模塊,把資源文件編譯到聯系人目錄中 . build/envsetup.sh mmm packages/apps/Contacts 4. 刷新 android 源碼工程,這個時候你就可以在 Contacts 包目錄下看到你新加的資源文件和源文件了, 並可以在源碼工程下修改代碼並直接調試了 5. ?? 為什麼不在 android 源碼工程下直接添加源文件和 xml 資源文件了???? 答: 因為我們的 android 源碼工程師以 java 工程導入的, 如果添加 android 的 xml 文件的話, java 程序無法識別資源 R 文件,所以我們必須先把需要的 xml 資源文件先在 linux 下編譯 6. 在源碼工程修改後,則可在 linux 下再次執行聯系人編譯命令,並 make snod 載入 system.img 文件, 並啟動模擬器(emulator &),就可以看到你的修改了。 2011-04-19 修改 Android 源碼的 Launcher 的例子 博客分類: ? Android AndroidOSUI 框架 Android 的 Launcher 研究:客制化桌面 UI 前言 能取得 Android OS 原始碼,並修改里頭的內容,有時候也頗有樂趣。最近和幾位朋友聊到 「Android 框架的改造」,以及如何吸引對 Android 框架技術有興趣的同好 一起交流的議 題;我個人認為,一開始如果能丟出一個比較有樂趣的議題,或許可以有拋磚引玉的效果。 上周在北京進行 Android 培訓課程時,與 eoeAndroid 社群也進行了想法的交流,由於大家 都體認到 Android 底層技術的重要性及其價 值, 而且 eoeAndroid 社群里也有許多技術好手, 所以就和 eoeAndroid 的創辦人靳岩兄有了一個共同主持研究 Android 底層技術 「同好小 組」 的想法,希望能透過社群的方式,集合大家的智慧,一起把底層技術研究清楚。 因為要讓大家能有焦點,所以「發題」很重要,這個工作就由落在我身上了。由於第一次希 望題目能簡單,並且有趣一點,至少要能達到發球的效果,吸引大家開始關心 Android 底層 技術,所以原則是:希望能用最簡單的方式、讓大家體驗修改底層的樂趣。 題目說明: Launcher 第一次的題目是「Launcher」的修改。 Launcher 就是 Android 的應用程式啟動器,Launcher 的功能還包含:桌面的切換、應用程 式快捷(shortcut)功能、背景圖(Wallpaper)功能等等。因此,修改 Launcher 可以改變一些 很深層的 UI 功能。 在 Android 的桌面最下方, 有一個圖示, 按下後可以拉出應用程式圖示清單, 這是 Launcher 提供的功能。這一次,因為我們覺得這個 Launcher 的圖示太制式化了,越看越不好看,所 以想要修改一下,換張圖,要怎麼做到呢? 範例展示 例如,圖 1 是原始的圖示;圖 2 是修改後的圖示。 圖 1: 原始圖示 圖 2: 幫 Launcher 妝扮一下 實作說明 1/4: 取得 Android 原始碼與 EeePC 移植 這個功能並不難做,事實上,完全不用寫程式。只要把圖檔重做就可以了。只不過前提是, 要知道: 1. 如何取得 Android OS 原始程式碼 2. 如何編譯 Android OS 最簡單的做法是: 1. 下載 Android 原始碼後、取得 EeePC 的移植(proct) 2. 編譯「TARGET_PRODUCT」為 eee_701 3. 由於 Launcher 都是用 Java 語法寫成的, 所以不會有架構(ARM/x86/...)的問題, 編譯後 可以取得 Launcher.apk;APK 套件是不分處理器平台的 先學會如何由 Android 原始碼編譯出 eee_701 的 image,才有辦法繼續進行 實作說明 2/4: 修改圖檔 在 Android 原始碼的 packages/apps/ 目錄里,存放了 Android 內建的應用程式原始碼, Launcher 是 Android 的一個應用程式,所以從這里找到它的原始碼,並進行修改工程。 切換到以下目錄: <android source>/packages/apps/Launcher/ 接著要修改 src/目錄下的內容,還是 res/目錄下的內容呢?圖檔屬於 Android 的 「resource」,因此當然是到 res/目錄下找到我們要的圖檔。 切換到以下目錄: <android source>/packages/apps/Launcher/res/ 又看到了一大堆目錄,圖檔的部份存放於: ? ? drawable-land/ - landscope 模式的圖檔 drawable-port/ - portrait 模式的圖檔 我們先改一下 portrait 模式的圖檔。 找到 drawable-port/tray_handle_normal.png 檔案如 下: 就是它了,換掉,把圖檔換成這個: 換好後重編 Android 即可。一行程式都不用改。 實作說明 3/4: 安裝 Launcher.apk 重編 Android 原始碼,接著可以在 out/target/proct/<proct name>/system/app/找到 Launcher.apk 套件。把 Launcher.apk 安裝到 AVD(Android 模擬器)里做測試,方法如下: 1. 先啟動一個 AVD 2. 執行 adb 將 Launcher.apk 手動安裝到 AVD 里,指令如下: $ adb install -r <your-path>/Launcher.apk

㈢ android怎樣自定義dialog

Android開發過程中,常常會遇到一些需求場景——在界面上彈出一個彈框,對用戶進行提醒並讓用戶進行某些選擇性的操作,
如退出登錄時的彈窗,讓用戶選擇「退出」還是「取消」等操作。
Android系統提供了Dialog類,以及Dialog的子類,常見如AlertDialog來實現此類功能。
一般情況下,利用Android提供的Dialog及其子類能夠滿足多數此類需求,然而,其不足之處體現在:
1. 基於Android提供的Dialog及其子類樣式單一,風格上與App本身風格可能不太協調;
2. Dialog彈窗在布局和功能上有所限制,有時不一定能滿足實際的業務需求。
本文將通過在Dialog基礎上構建自定義的Dialog彈窗,以最常見的確認彈框為例。
本樣式相對比較簡單:上面有一個彈框標題(提示語),下面左右分別是「確認」和「取消」按鈕,當用戶點擊「確認」按鈕時,彈框執行
相應的確認邏輯,當點擊「取消」按鈕時,執行相應的取消邏輯。
首先,自定義彈框樣式:

1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent"
4 android:layout_height="wrap_content"
5 android:background="@drawable/dialog_bg"
6 android:orientation="vertical" >
7
8 <TextView
9 android:id="@+id/title"
10 android:layout_width="wrap_content"
11 android:layout_height="wrap_content"
12 android:layout_gravity="center"
13 android:paddingTop="14dp"
14 android:textColor="@color/login_hint"
15 android:textSize="@dimen/text_size_18" />
16
17 <LinearLayout
18 android:layout_width="match_parent"
19 android:layout_height="wrap_content"
20 android:layout_marginBottom="14dp"
21 android:layout_marginLeft="20dp"
22 android:layout_marginRight="20dp"
23 android:layout_marginTop="30dp" >
24
25 <TextView
26 android:id="@+id/confirm"
27 android:layout_width="wrap_content"
28 android:layout_height="wrap_content"
29 android:layout_marginRight="10dp"
30 android:layout_weight="1"
31 android:background="@drawable/btn_confirm_selector"
32 android:gravity="center"
33 android:textColor="@color/white"
34 android:textSize="@dimen/text_size_16" />
35
36 <TextView
37 android:id="@+id/cancel"
38 android:layout_width="wrap_content"
39 android:layout_height="wrap_content"
40 android:layout_marginLeft="10dp"
41 android:layout_weight="1"
42 android:background="@drawable/btn_cancel_selector"
43 android:gravity="center"
44 android:textColor="@color/login_hint"
45 android:textSize="@dimen/text_size_16" />
46 </LinearLayout>
47
48 </LinearLayout>

然後,通過繼承Dialog類構建確認彈框控制項ConfirmDialog:

1 package com.corn.widget;
2
3 import android.app.Dialog;
4 import android.content.Context;
5 import android.os.Bundle;
6 import android.util.DisplayMetrics;
7 import android.view.LayoutInflater;
8 import android.view.View;
9 import android.view.Window;
10 import android.view.WindowManager;
11 import android.widget.TextView;
12
13 import com.corn.R;
14
15 public class ConfirmDialog extends Dialog {
16
17 private Context context;
18 private String title;
19 private String confirmButtonText;
20 private String cacelButtonText;
21 private ClickListenerInterface clickListenerInterface;
22
23 public interface ClickListenerInterface {
24
25 public void doConfirm();
26
27 public void doCancel();
28 }
29
30 public ConfirmDialog(Context context, String title, String confirmButtonText, String cacelButtonText) {
31 super(context, R.style.MyDialog);
32 this.context = context;
33 this.title = title;
34 this.confirmButtonText = confirmButtonText;
35 this.cacelButtonText = cacelButtonText;
36 }
37
38 @Override
39 protected void onCreate(Bundle savedInstanceState) {
40 // TODO Auto-generated method stub
41 super.onCreate(savedInstanceState);
42
43 init();
44 }
45
46 public void init() {
47 LayoutInflater inflater = LayoutInflater.from(context);
48 View view = inflater.inflate(R.layout.confirm_dialog, null);
49 setContentView(view);
50
51 TextView tvTitle = (TextView) view.findViewById(R.id.title);
52 TextView tvConfirm = (TextView) view.findViewById(R.id.confirm);
53 TextView tvCancel = (TextView) view.findViewById(R.id.cancel);
54
55 tvTitle.setText(title);
56 tvConfirm.setText(confirmButtonText);
57 tvCancel.setText(cacelButtonText);
58
59 tvConfirm.setOnClickListener(new clickListener());
60 tvCancel.setOnClickListener(new clickListener());
61
62 Window dialogWindow = getWindow();
63 WindowManager.LayoutParams lp = dialogWindow.getAttributes();
64 DisplayMetrics d = context.getResources().getDisplayMetrics(); // 獲取屏幕寬、高用
65 lp.width = (int) (d.widthPixels * 0.8); // 高度設置為屏幕的0.6
66 dialogWindow.setAttributes(lp);
67 }
68
69 public void setClicklistener(ClickListenerInterface clickListenerInterface) {
70 this.clickListenerInterface = clickListenerInterface;
71 }
72
73 private class clickListener implements View.OnClickListener {
74 @Override
75 public void onClick(View v) {
76 // TODO Auto-generated method stub
77 int id = v.getId();
78 switch (id) {
79 case R.id.confirm:
80 clickListenerInterface.doConfirm();
81 break;
82 case R.id.cancel:
83 clickListenerInterface.doCancel();
84 break;
85 }
86 }
87
88 };
89
90 }

在如上空間構造代碼中,由於控制項的"確認"和"取消"邏輯與實際的應用場景有關,因此,控制項中通過定義內部介面來實現。

在需要使用此控制項的地方,進行如下形式調用:

1 public static void Exit(final Context context) {
2 final ConfirmDialog confirmDialog = new ConfirmDialog(context, "確定要退出嗎?", "退出", "取消");
3 confirmDialog.show();
4 confirmDialog.setClicklistener(new ConfirmDialog.ClickListenerInterface() {
5 @Override
6 public void doConfirm() {
7 // TODO Auto-generated method stub
8 confirmDialog.dismiss();
9 //toUserHome(context);
10 AppManager.getAppManager().AppExit(context);
11 }
12
13 @Override
14 public void doCancel() {
15 // TODO Auto-generated method stub
16 confirmDialog.dismiss();
17 }
18 });
19 }

調用中實現了此控制項的內部介面,並賦給控制項本身,以此在點擊按鈕時實現基於外部具體業務邏輯的函數回調。

㈣ android自定義的對話框怎麼調用

Android自定義對話框的思路就是編寫對話框的布局文件xml,然後在對話框中顯示不同的控制項。以下以顯示文本控制項為例(ImageView等都可以顯示)。
1.布局文件connect_dlg.xml(比如http://www.tiecou.com/)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#ffffffff"
android:orientation="vertical"
android:id="@+id/llToast" >
<TextView
android:layout_height="wrap_content"
android:layout_margin="1dip"
android:textColor="#ffffffff"
android:layout_width="fill_parent"
android:gravity="center"
android:textSize="16sp"
android:background="#FF129de2"
android:id="@+id/tvTitleToast" />
<LinearLayout
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/llToastContent"
android:layout_marginLeft="1dip"
android:layout_marginRight="1dip"
android:layout_marginBottom="1dip"
android:layout_width="wrap_content"
android:padding="15dip"
android:background="#FFFFFFFF" >
<TextView
android:layout_height="wrap_content"
android:paddingRight="10dip"
android:paddingLeft="10dip"
android:layout_width="wrap_content"
android:gravity="center"
android:textSize="16sp"
android:textColor="#FFff6699"
android:id="@+id/tvTextToast" />
</LinearLayout>
<LinearLayout
android:id="@+id/MyLayout_ad2"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="40sp">
<com.tencent.exmobwin.banner.TAdView
android:id="@+id/adview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|right" >
</com.tencent.exmobwin.banner.TAdView>
</LinearLayout>
</LinearLayout>
2.編寫顯示對話框函數。ShowConnectDialog(String textString)
private void ShowConnectDialog(String textString) {
LinearLayout loginLayout1 = (LinearLayout) getLayoutInflater().inflate(
R.layout.connect_dlg, null);
// adView.
TextView title = (TextView) loginLayout1
.findViewById(R.id.tvTitleToast);
title.setText("系統提示");
TextView text1 = (TextView) loginLayout1.findViewById(R.id.tvTextToast);
text1.setText(textString);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(loginLayout1);
builder.setPositiveButton("下載MobCtrl伺服器?", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//處理確定按鈕
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// 處理取消按鈕
finish();
}
});
builder.create().show();
}
3.顯示對話框。在需要顯示的地方調用即可。
ShowConnectDialog("連接超時,請檢查伺服器是否開啟及IP地址是否輸入正確。確保電腦和手機連接在同一個網路內。");

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:1644
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:1862
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:1681
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:1720
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:1559
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:2024
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:1168
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:1109
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:1735
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:1859