① android設置dialog在第幾層顯示
android中dialog都是彈出的對話框,沒有第幾層這個概念,只有dialog有級別。
具體實現代碼:
1.創建對象框
AlertDialog.Builder builder = new Builder(context);
builder.setTitle("請輸入"); //設置對話框標題
builder.setIcon(android.R.drawable.btn_star); //設置對話框標題前的圖標
2.創建EditText輸入框
final EditText edit = new EditText(context);
3.將輸入框賦值給Dialog,並增加確定取消按鍵
builder.setView(edit);
builder.setPositiveButton("確認", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(context, "你輸入的是: " + edit.getText().toString(), Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(context, "你點了取消", Toast.LENGTH_SHORT).show();
}
});
4.設置常用api,並show彈出
builder.setCancelable(true); //設置按鈕是否可以按返回鍵取消,false則不可以取消
AlertDialog dialog = builder.create(); //創建對話框
dialog.setCanceledOnTouchOutside(true); //設置彈出框失去焦點是否隱藏,即點擊屏蔽其它地方是否隱藏
dialog.show();
② Android 自定義鍵盤點擊按鍵出現的浮層怎樣去掉
那個不是TextView是EditText,你只要把EditText放在Button上面就行了代碼如下:粘進去運行就行了activity隨便寫個就行記得配manifest~~~
③ android使用百度地圖3.0版本怎樣實現自定義彈出窗口功能
基本原理就是用ItemizedOverlay來添加附加物,在OnTap方法中向MapView上添加一個自定義的View(如果已存在就直接設為可見),下面具體來介紹我的實現方法:
一、自定義覆蓋物類:MyPopupOverlay,這個類是最關鍵的一個類ItemizedOverlay,用於設置Marker,並定義Marker的點擊事件,彈出窗口,至於彈出窗口的內容,則通過定義Listener,放到Activity中去構造。如果沒有特殊需求,這個類不需要做什麼改動。代碼如下,popupLinear這個對象,就是加到地圖上的自定義View:
java"><OverlayItem>{
privateContextcontext=null;
//這是彈出窗口,包括內容部分還有下面那個小三角
=null;
//這是彈出窗口的內容部分
private
ViewpopupView=null;
privateMapViewmapView=null;
private
Projectionprojection=null;
//這是彈出窗口內容部分使用的layoutId,在Activity中設置
privateintlayoutId=
0;
//是否使用網路帶有A-J字樣的Marker
=
false;
privateint[]defaultMarkerIds={
R.drawable.icon_marka,
R.drawable.icon_markb,
R.drawable.icon_markc,
R.drawable.icon_markd,
R.drawable.icon_marke,
R.drawable.icon_markf,
R.drawable.icon_markg,
R.drawable.icon_markh,
R.drawable.icon_marki,
R.drawable.icon_markj,};
//這個Listener用於在Marker被點擊時讓Activity填充PopupView的內容
private
OnTapListeneronTapListener=null;
publicMyPopupOverlay(Contextcontext,Drawablemarker,MapViewmMapView)
{
super(marker,mMapView);
this.context=
context;
this.popupLinear=newLinearLayout(context);
this.mapView=mMapView;
popupLinear.setOrientation(LinearLayout.VERTICAL);
popupLinear.setVisibility(View.GONE);
projection=
mapView.getProjection();
}
@Override
publicbooleanonTap(GeoPointpt,MapViewmMapView)
{
//點擊窗口以外的區域時,當前窗口關閉
if(popupLinear!=null&&
popupLinear.getVisibility()==View.VISIBLE){
LayoutParamslp=
(LayoutParams)popupLinear.getLayoutParams();
PointtapP=new
Point();
projection.toPixels(pt,tapP);
PointpopP
=newPoint();
projection.toPixels(lp.point,
popP);
intxMin=popP.x-lp.width/2+lp.x;
intyMin=popP.y-lp.height+lp.y;
intxMax=popP.x+
lp.width/2+lp.x;
intyMax=popP.y+lp.y;
if
(tapP.x<xMin||tapP.y<yMin||tapP.x>xMax
||tapP.y>yMax)
popupLinear.setVisibility(View.GONE);
}
return
false;
}
@Override
protectedbooleanonTap(inti){
//
點擊Marker時,該Marker滑動到地圖中央偏下的位置,並顯示Popup窗口
OverlayItemitem=
getItem(i);
if(popupView==null){
//
如果popupView還沒有創建,則構造popupLinear
if
(!createPopupView()){
returntrue;
}
}
if(onTapListener==null)
return
true;
popupLinear.setVisibility(View.VISIBLE);
onTapListener.onTap(i,popupView);
popupLinear.measure(0,0);
intviewWidth=
popupLinear.getMeasuredWidth();
intviewHeight=
popupLinear.getMeasuredHeight();
LayoutParamslayoutParams=newLayoutParams(viewWidth,
viewHeight,
item.getPoint(),0,-60,
LayoutParams.BOTTOM_CENTER);
layoutParams.mode=
LayoutParams.MODE_MAP;
popupLinear.setLayoutParams(layoutParams);
Pointp=new
Point();
projection.toPixels(item.getPoint(),p);
p.y=
p.y-viewHeight/2;
GeoPointpoint=projection.fromPixels(p.x,
p.y);
mapView.getController().animateTo(point);
return
true;
}
privatebooleancreatePopupView(){
//TODOAuto-generated
methodstub
if(layoutId==0)
return
false;
popupView=LayoutInflater.from(context).inflate(layoutId,
null);
popupView.setBackgroundResource(R.drawable.popupborder);
ImageView
dialogStyle=newImageView(context);
dialogStyle.setImageDrawable(context.getResources().getDrawable(
R.drawable.iw_tail));
popupLinear.addView(popupView);
android.widget.LinearLayout.LayoutParamslp=new
android.widget.LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
lp.topMargin=
-2;
lp.leftMargin=60;
popupLinear.addView(dialogStyle,
lp);
mapView.addView(popupLinear);
returntrue;
}
@Override
publicvoidaddItem(List<OverlayItem>items)
{
//TODOAuto-generatedmethodstub
intstartIndex=
getAllItem().size();
for(OverlayItemitem:items){
if(startIndex>=defaultMarkerIds.length)
startIndex=
defaultMarkerIds.length-1;
if(useDefaultMarker&&
item.getMarker()==null){
item.setMarker(context.getResources().getDrawable(
defaultMarkerIds[startIndex++]));
}
}
super.addItem(items);
}
@Override
publicvoidaddItem(OverlayItemitem){
//
TODOAuto-generatedmethodstub
//
重載這兩個addItem方法,主要用於設置自己默認的Marker
intindex=
getAllItem().size();
if(index>=
defaultMarkerIds.length)
index=defaultMarkerIds.length-
1;
if(useDefaultMarker&&item.getMarker()==
null){
item.setMarker(context.getResources().getDrawable(
defaultMarkerIds[getAllItem().size()]));
}
super.addItem(item);
}
publicvoidsetLayoutId(intlayoutId){
this.layoutId=
layoutId;
}
publicvoidsetUseDefaultMarker(booleanuseDefaultMarker){
this.useDefaultMarker=useDefaultMarker;
}
publicvoidsetOnTapListener(OnTapListeneronTapListener){
this.onTapListener=onTapListener;
}
publicinterfaceOnTapListener{
publicvoidonTap(intindex,
ViewpopupView);
}
}
二、MainActivity,這是主界面,用來顯示地圖,創建MyPopupOverlay對象,在使用我寫的MyPopupOverlay這個類時,需要遵循以下步驟:
創建MyPopupOverlay對象,構造函數為public MyPopupOverlay(Context context, Drawable marker, MapView mMapView),四個參數分別為當前的上下文、通用的Marker(這是ItemizedOverlay需要的,當不設置Marker時的默認Marker)以及網路地圖對象。
設置自定義的彈出窗口內容的布局文件ID,使用的方法為public void setLayoutId(int layoutId)。
設置是使用自定義的Marker,還是預先寫好的帶有A-J字樣的網路地圖原裝Marker,使用的方法為public void setUseDefaultMarker(boolean useDefaultMarker),只有當這個值為true且沒有調用OverlayItem的setMarker方法為特定點設置Marker時,才使用原裝Marker。
創建Marker所在的點,即分別創建一個個OverlayItem,然後調用public void addItem(OverlayItem item)或public void addItem(List<OverlayItem> items)方法來把這些OverlayItem添加到自定義的附加層上去。
為MyPopupOverlay對象添加onTap事件,當Marker被點擊時,填充彈出窗口中的內容(也就是第2條中layoutId布局中的內容),設置方法為public void setOnTapListener(OnTapListener onTapListener),OnTapListener是定義在MyPopupOverlay中的介面,實現這個介面需要覆寫public void onTap(int index, View popupView)方法,其中,index表示被點擊的Marker(確切地說是OverlayItem)的索引,popupView是使用layoutId這個布局的View,也就是彈出窗口除了下面的小三角之外的部分。
把這個MyPopupOverlay對象添加到地圖上去:mMapView.getOverlays().add(myOverlay);mMapView.refresh();
④ 請教實現android工程中點擊菜單彈出一個對話框
說下思路的,既然是彈出對話框,肯定是需要一個dialog,既然這個dialog中的一些屬性是自己設定的,肯定是要設置自己自定義的dialog,怎麼樣才能彈出dialog呢,當你監聽點擊菜單的事件,記得幾貼喲,邏輯很重要的,其他的就要靠你自己的了
android 點擊按鈕 讓菜單從上面彈出
分類: 移動開發/ Android/ 文章
VC/MFC 菜單從繪,點擊菜單項目發送自定義消息,彈出afxMessagebox("1");//報錯
菜單自繪,點擊菜單項目發送自定義消息,彈出afxMessagebox("1");//報錯wm_buttondown消息里//自定義消息SendMessage發送自定義消息,報錯。換成PostMessage就沒事。這是啥原理? 解決方案貼相關
VC/MFC 怎麼點擊按鈕彈出右鍵菜單,並且按鈕保持按上狀態
如何點擊按鈕彈出右鍵菜單,並且按鈕保持按下狀態?環境:VS2008 MFC問題:我重繪了按鈕,分為3個狀態:正常、滑鼠進入、滑鼠按下;當點擊滑鼠時會在按鈕下面彈出右鍵菜單。現在問題是右鍵菜單彈出後,按鈕的按下狀態就消失了!!請問如何在彈出菜單時使按鈕保持按下狀態,在菜單消失時按鈕狀態恢復正常?解決方案你試試看設立一個
VC/MFC MDI怎麼實現一個功能,菜單下點擊一個按鈕彈出一個ClistView
MDI如何實現一個功能,菜單上點擊一個按鈕彈出一個ClistView?MDI如何實現一個功能,菜單上點擊一個按鈕彈出一個ClistView?注意是CListView,不是彈對話框。這個功能怎麼實現啊??解決方案 CDockablePane ?用VS2008SP1/VS2010建個SDI/MDI工程就看到了
Android Android點按鈕彈出系統菜單的方法,該如何處理
Android點按鈕彈出系統菜單的方法不點擊menu按鈕、點擊自定義的按鈕彈出系統的menu菜單如何實現、菜鳥請教、解決方案http://www.eoeandroid.com/thread-69418-1-1.html 解決方案 調用這句KeyEvent event=new KeyEvent
Delphi 小弟我想點擊菜單上面的一個按鈕後,直接就類式與按下了PrintScreen鍵,但是小弟我對鍵盤消息不是很清楚,大俠
我想點擊菜單上面的一個按鈕後,直接就類式與按下了PrintScreen鍵,但是我對鍵盤消息不是很清楚,請教各位大俠!我是這樣實現的: 在按鈕的單擊事件裡面這樣寫的: SendMessage(Handle,WM_KEYUP,VK_SNAPSHOT,0
Android Android 彈出菜單 - PathButton
Android 彈出菜單 ---- PathButton http://www.oschina.net/p/pathbutton
Android 點擊彈出層如何處理點擊到上面層
點擊彈出層如何避免點擊到下面層 。如在原來的列表上 放了一個隱藏顯示的ReltionLayout 裡面放了一些 選項 選擇排序或過濾條件,這時在列表上面彈出顯示這個ReltionLayout ,點擊這個ReltionLayout 空白處 沒有剛好點擊
C++ VS2010點擊菜單彈出對話框解決方案
VS2010點擊菜單彈出對話框在mfc下,新建一個菜單項,然後給它加一個消息處理函數,就是彈出一個對話框的。但是,加一個消息處理函數的前提是這個菜單的Popup屬性是false,可是,當popup屬性是false的時候,程序運行出來那個菜單項是灰色的,根本點不動,更不用說彈出對話框了。不知道這個情況大家有沒有遇到過呢
Web前端 jQuery點擊彈出上拉菜單
jQuery點擊彈出下拉菜單<title>導航——點擊彈出內容</title> <style type="text/css"> .navgation{margin:0;padding:0;list-style-type:none
Android android彈出菜單銀屏移動
android彈出菜單屏幕移動有這樣一個效果:從屏幕左邊彈出一個寬度為w對話框,然後屏幕裡面的activity就往左邊移動w距離。請問用什麼方法可以實現這個方法呢解決方案
ASP.NET 點擊按鈕彈出網頁的有關問題
點擊按鈕彈出網頁的問題請問一下各位,我在網頁上放置一個按鈕,點擊時彈出另一個頁面,在我的機子上運行時可以彈出,當把網站打包安裝到另一台電腦時,點擊按鈕,就彈不出網頁,這是是么問題,謝謝! 我按鈕中的代碼是這樣的 protected void
VB VB怎麼點擊網頁彈出提示窗口的按鈕
VB如何點擊網頁彈出提示窗口的按鈕某網頁,點擊按鈕後會出現一個彈出窗口,在網上找,在CSDN上問,會找出其彈出窗口的文字內容了,但是其上面還有是、否或確定取消一兩個按鈕,我現在不會點這個按鈕,大家支下招哈!解決方案 幫樓主頂一下... 解決方案 你這其實是一個dhtml問題吧,壇子中常有類似的問題的,搜索一下吧
VC/MFC 點擊按鈕後彈出另一個對話框解決方法
點擊按鈕後彈出另一個對話框用CDialog類做出一個選擇界面:一個按鈕 點擊此按鈕後,會彈出另外的一個對話框按鈕(裡面可以有輸入命令的編輯框,也有可以點擊確定的按鈕) 請問,該如何實現上述的功能? 如何調用? 請詳細些,謝謝!解決方案在擬新建的對話框類中加入Create 調用即可。 解決方案無模式
Java Web開發 點擊按鈕,彈出保存、打開對話框解決方案
點擊按鈕,彈出保存、打開對話框怎樣在html頁面上加按鈕跟響應實現這個功能?就比如像平時網頁上看到的下載,一點就出來個對話框,有打開,保存,取消的,點保存還能選擇保存路徑的,怎麼搞???解決方案你只要把文件鏈接放到頁面上,其他的就是瀏覽器的事情了。 解決方案探討你只要把文件鏈接放到頁面上,其他的就是瀏覽器的事情
ASP.NET 如何點擊按鈕彈出一個小窗口
怎麼點擊按鈕彈出一個小窗口?我做的是投票系統點擊投票按鈕彈出一個小窗口 小窗口裡面是投票用的!~解決方案先做個隱藏的DIV,點擊時再顯示 解決方案window.openwindow.showModalDialogDiv第三方控制項 解決方案javascript 解決方案傳值可以跟url傳一樣吧。。?UserID
⑤ 如何在進入app程序之前自動彈出一個自定義界面
直接在android虛擬機的"應用管理"中卸載指定程序即可
關於android虛擬機調試APP程序的說明:
1.建立虛擬機
首先,根據測試模擬需要配置一個虛擬機,如下圖所示,打開Eclipse軟體後,在主界面點擊Android Virtual Device Manager,出現虛擬機管理界面,點擊New按鈕彈出虛擬機參數配置界面,選擇適宜的虛擬機參數比如屏幕大小、解析度、內存RAM、SD卡大小等,填入後點擊OK創建完畢後關閉虛擬機管理頁面。
2.建立Android工程
建立默認參數的Android工程,在進行模擬器時,請確保你建立的工程沒有錯誤。
3.運行android 應用
點擊工程 run as android application後,系統就會啟動虛擬機,在剛開始時虛擬機界面如下,一段時間後,會運行相關的程序。
注意事項:
在模擬器測試前,必須先確保已經正確的建立工程;
虛擬機建立時會進行一系列內部操作,需要花較長時間,建議,在建立一個虛擬機後不要關閉虛擬機界面,直接切換不用的工程,就可以運行不同的APP!
⑥ android studio彈出設置頁面
android studio彈出設置頁面?Android向上彈出設置窗口
工具原料Android
方法/步驟分步閱讀
1
/6
1.PopupWindow是Android上自定義彈出窗口
PopupWindow的構造函數為
2
/6
2.主界面的layout為:
3
/6
3.PopupWindow的layout為:
4
/6
4.Activity的代碼為:
5
/6
5.這三行代碼
6
/6
6.測試的結果為
內容僅供參考並受版權保護
⑦ android如何寫一個自定義的dialog可以在Title的位置彈出來
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/title_height"
android:background="@drawable/bg_top_title"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="20sp"
android:layout_centerInParent="true"/>
<ImageView
android:layout_width="@dimen/header_btn_width"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_alignParentTop="true"
android:paddingLeft="4dp"
android:id="@+id/right_button"
android:src="@drawable/arrow_dropdown_pressed"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
彈出的dialog的Layout為
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/dropdownBckgrnd"
android:background="@drawable/bg_pop_up_dimmer"
>
<ImageView
android:layout_width="@dimen/header_btn_width"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_alignParentTop="true"
android:paddingLeft="4dp"
android:id="@+id/right_button"
android:src="@drawable/arrow_dropdown_pressed"
android:layout_alignParentRight="true"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="35dp"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="@drawable/topmenu_popup_down">
<Button
android:layout_width="fill_parent"
android:layout_height="45dp"
android:background="@drawable/main_menu_button_background"
android:layout_margin="@dimen/button_margin_top"
android:text="aaa"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="45dp"
android:background="@drawable/main_menu_button_background"
android:layout_margin="@dimen/button_margin_top"
android:text="bbb"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="45dp"
android:background="@drawable/main_menu_button_background"
android:layout_margin="@dimen/button_margin_top"
android:text="ccc"
/>
</LinearLayout>
</RelativeLayout>
⑧ android 如何實現點擊imageview彈出自定義的窗口activity
先給你的ImageView設置OnClickListener或者OnTouchListener,然後在onClick或者onTouch方法里拋出Intent來啟動你需要的activity
⑨ android開發百度地圖怎麼實現自定義彈出窗口
基本原理就是用ItemizedOverlay來添加附加物,在OnTap方法中向MapView上添加一個自定義的View(如果已存在就直接設為可見),下面具體來介紹我的實現方法:
一、自定義覆蓋物類:MyPopupOverlay,這個類是最關鍵的一個類ItemizedOverlay,用於設置Marker,並定義Marker的點擊事件,彈出窗口,至於彈出窗口的內容,則通過定義Listener,放到Activity中去構造。如果沒有特殊需求,這個類不需要做什麼改動。代碼如下,popupLinear這個對象,就是加到地圖上的自定義View:
public class MyPopupOverlay extends ItemizedOverlay<OverlayItem> {
private Context context = null;
// 這是彈出窗口, 包括內容部分還有下面那個小三角
private LinearLayout popupLinear = null;
// 這是彈出窗口的內容部分
private View popupView = null;
private MapView mapView = null;
private Projection projection = null;
// 這是彈出窗口內容部分使用的layoutId,在Activity中設置
private int layoutId = 0;
// 是否使用網路帶有A-J字樣的Marker
private boolean useDefaultMarker = false;
private int[] defaultMarkerIds = { R.drawable.icon_marka,
R.drawable.icon_markb, R.drawable.icon_markc,
R.drawable.icon_markd, R.drawable.icon_marke,
R.drawable.icon_markf, R.drawable.icon_markg,
R.drawable.icon_markh, R.drawable.icon_marki,
R.drawable.icon_markj, };
// 這個Listener用於在Marker被點擊時讓Activity填充PopupView的內容
private OnTapListener onTapListener = null;
public MyPopupOverlay(Context context, Drawable marker, MapView mMapView) {
super(marker, mMapView);
this.context = context;
this.popupLinear = new LinearLayout(context);
this.mapView = mMapView;
popupLinear.setOrientation(LinearLayout.VERTICAL);
popupLinear.setVisibility(View.GONE);
projection = mapView.getProjection();
}
@Override
public boolean onTap(GeoPoint pt, MapView mMapView) {
// 點擊窗口以外的區域時,當前窗口關閉
if (popupLinear != null && popupLinear.getVisibility() == View.VISIBLE) {
LayoutParams lp = (LayoutParams) popupLinear.getLayoutParams();
Point tapP = new Point();
projection.toPixels(pt, tapP);
Point popP = new Point();
projection.toPixels(lp.point, popP);
int xMin = popP.x - lp.width / 2 + lp.x;
int yMin = popP.y - lp.height + lp.y;
int xMax = popP.x + lp.width / 2 + lp.x;
int yMax = popP.y + lp.y;
if (tapP.x < xMin || tapP.y < yMin || tapP.x > xMax
|| tapP.y > yMax)
popupLinear.setVisibility(View.GONE);
}
return false;
}
@Override
protected boolean onTap(int i) {
// 點擊Marker時,該Marker滑動到地圖中央偏下的位置,並顯示Popup窗口
OverlayItem item = getItem(i);
if (popupView == null) {
// 如果popupView還沒有創建,則構造popupLinear
if (!createPopupView()){
return true;
}
}
if (onTapListener == null)
return true;
popupLinear.setVisibility(View.VISIBLE);
onTapListener.onTap(i, popupView);
popupLinear.measure(0, 0);
int viewWidth = popupLinear.getMeasuredWidth();
int viewHeight = popupLinear.getMeasuredHeight();
LayoutParams layoutParams = new LayoutParams(viewWidth, viewHeight,
item.getPoint(), 0, -60, LayoutParams.BOTTOM_CENTER);
layoutParams.mode = LayoutParams.MODE_MAP;
popupLinear.setLayoutParams(layoutParams);
Point p = new Point();
projection.toPixels(item.getPoint(), p);
p.y = p.y - viewHeight / 2;
GeoPoint point = projection.fromPixels(p.x, p.y);
mapView.getController().animateTo(point);
return true;
}
private boolean createPopupView() {
// TODO Auto-generated method stub
if (layoutId == 0)
return false;
popupView = LayoutInflater.from(context).inflate(layoutId, null);
popupView.setBackgroundResource(R.drawable.popupborder);
ImageView dialogStyle = new ImageView(context);
dialogStyle.setImageDrawable(context.getResources().getDrawable(
R.drawable.iw_tail));
popupLinear.addView(popupView);
android.widget.LinearLayout.LayoutParams lp = new android.widget.LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lp.topMargin = -2;
lp.leftMargin = 60;
popupLinear.addView(dialogStyle, lp);
mapView.addView(popupLinear);
return true;
}
@Override
public void addItem(List<OverlayItem> items) {
// TODO Auto-generated method stub
int startIndex = getAllItem().size();
for (OverlayItem item : items){
if (startIndex >= defaultMarkerIds.length)
startIndex = defaultMarkerIds.length - 1;
if (useDefaultMarker && item.getMarker() == null){
item.setMarker(context.getResources().getDrawable(
defaultMarkerIds[startIndex++]));
}
}
super.addItem(items);
}
@Override
public void addItem(OverlayItem item) {
// TODO Auto-generated method stub
// 重載這兩個addItem方法,主要用於設置自己默認的Marker
int index = getAllItem().size();
if (index >= defaultMarkerIds.length)
index = defaultMarkerIds.length - 1;
if (useDefaultMarker && item.getMarker() == null){
item.setMarker(context.getResources().getDrawable(
defaultMarkerIds[getAllItem().size()]));
}
super.addItem(item);
}
public void setLayoutId(int layoutId) {
this.layoutId = layoutId;
}
public void setUseDefaultMarker(boolean useDefaultMarker) {
this.useDefaultMarker = useDefaultMarker;
}
public void setOnTapListener(OnTapListener onTapListener) {
this.onTapListener = onTapListener;
}
public interface OnTapListener {
public void onTap(int index, View popupView);
}
}
⑩ 安卓開發 自定義界面的彈窗
viewDialog= (Button)findViewById(R.id.viewdialog);
viewDialog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog();
}
});
public void showDialog(){
Dialog dialog = new Dialog(Main.this, R.style.DialogStyle);
dialog .requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog .getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
dialog .setContentView(R.layout.dialog);
dialog .show();
// WindowManager.LayoutParams params = dialog .getWindow().getAttributes();
// params.width = 800;
// params.height = 550 ;
// dialog .getWindow().setAttributes(params);
}
dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
注釋的部分是設置dialog的大小
listview跟在activity中添加一樣的,定義listview組件時加dialog.findbyid(...),arrayadapter網上資料很多,隨便看看