編輯:關於Android編程
package com.wwj.popupwindow; import android.app.Activity; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.widget.LinearLayout; import android.widget.PopupWindow; /** * 自定義popupWindow * * @author wwj * * */ public class AddPopWindow extends PopupWindow { private View conentView; public AddPopWindow(final Activity context) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); conentView = inflater.inflate(R.layout.add_popup_dialog, null); int h = context.getWindowManager().getDefaultDisplay().getHeight(); int w = context.getWindowManager().getDefaultDisplay().getWidth(); // 設置SelectPicPopupWindow的View this.setContentView(conentView); // 設置SelectPicPopupWindow彈出窗體的寬 this.setWidth(w / 2 + 50); // 設置SelectPicPopupWindow彈出窗體的高 this.setHeight(LayoutParams.WRAP_CONTENT); // 設置SelectPicPopupWindow彈出窗體可點擊 this.setFocusable(true); this.setOutsideTouchable(true); // 刷新狀態 this.update(); // 實例化一個ColorDrawable顏色為半透明 ColorDrawable dw = new ColorDrawable(0000000000); // 點back鍵和其他地方使其消失,設置了這個才能觸發OnDismisslistener ,設置其他控件變化等操作 this.setBackgroundDrawable(dw); // mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog); // 設置SelectPicPopupWindow彈出窗體動畫效果 this.setAnimationStyle(R.style.AnimationPreview); LinearLayout addTaskLayout = (LinearLayout) conentView .findViewById(R.id.add_task_layout); LinearLayout teamMemberLayout = (LinearLayout) conentView .findViewById(R.id.team_member_layout); addTaskLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { AddPopWindow.this.dismiss(); } }); teamMemberLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AddPopWindow.this.dismiss(); } }); } /** * 顯示popupWindow * * @param parent */ public void showPopupWindow(View parent) { if (!this.isShowing()) { // 以下拉方式顯示popupwindow this.showAsDropDown(parent, parent.getLayoutParams().width / 2, 18); } else { this.dismiss(); } } }
package com.wwj.popupwindow; import android.app.Activity; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.PopupWindow; public class MorePopWindow extends PopupWindow { private View conentView; public MorePopWindow(final Activity context) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); conentView = inflater.inflate(R.layout.more_popup_dialog, null); int h = context.getWindowManager().getDefaultDisplay().getHeight(); int w = context.getWindowManager().getDefaultDisplay().getWidth(); // 設置SelectPicPopupWindow的View this.setContentView(conentView); // 設置SelectPicPopupWindow彈出窗體的寬 this.setWidth(w / 2 + 50); // 設置SelectPicPopupWindow彈出窗體的高 this.setHeight(LayoutParams.WRAP_CONTENT); // 設置SelectPicPopupWindow彈出窗體可點擊 this.setFocusable(true); this.setOutsideTouchable(true); // 刷新狀態 this.update(); // 實例化一個ColorDrawable顏色為半透明 ColorDrawable dw = new ColorDrawable(0000000000); // 點back鍵和其他地方使其消失,設置了這個才能觸發OnDismisslistener ,設置其他控件變化等操作 this.setBackgroundDrawable(dw); // mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog); // 設置SelectPicPopupWindow彈出窗體動畫效果 this.setAnimationStyle(R.style.AnimationPreview); } public void showPopupWindow(View parent) { if (!this.isShowing()) { this.showAsDropDown(parent, parent.getLayoutParams().width / 2, 18); } else { this.dismiss(); } } }
package com.wwj.popupwindow; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity implements OnClickListener{ private Button setButton; private Button addButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_swipe); setButton = (Button) findViewById(R.id.btnSet); addButton = (Button) findViewById(R.id.btnAdd); setButton.setOnClickListener(this); addButton.setOnClickListener(this);; } @Override public void onClick(View v) { switch (v.getId()) { case R.id.btnSet: MorePopWindow morePopWindow = new MorePopWindow(MainActivity.this); morePopWindow.showPopupWindow(setButton); break; case R.id.btnSearch: break; case R.id.btnAdd: AddPopWindow addPopWindow = new AddPopWindow(MainActivity.this); addPopWindow.showPopupWindow(addButton); break; default: break; } } }
在很久很久之前,看過一篇關於內存洩露的文章,裡面列舉了比較全的應該注意的問題,後來找不到原文地址,今天翻了微博,找到了該文章,為了方便日後自己查看,將注意的問題提取出來。
大家好,趁著現在別人都去吃飯的時間,來給大家講一講React Native中Android部分的控件ViewPagerAndroid的講解,這裡特別提醒一下,我寫的博客都
1、Service概述Service的主要作用是,讓系統可以在後台干一些不與用戶交互的操作,這些操作可能會比較耗時,比如去下載一些網絡資源等;也可能是一項長期運行的工作,
前面幾篇博客,我們將了Android中利用OpenGL ES 2.0繪制各種形體,並在上一篇博客中專門講了GLSL語言。但是我們看到的基於OpenGL開發的應用和游戲,可