編輯:關於Android編程
直接上效果圖:
實現步驟:
1.主界面activity_main.xml很簡單,一個按鈕
2.彈出層樣式actionsheet.xml
3.ActionSheet類
public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton); } private ActionSheet() { } public static Dialog showSheet(Context context, final OnActionSheetSelected actionSheetSelected, OnCancelListener cancelListener) { final Dialog dlg = new Dialog(context, R.style.ActionSheet); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.actionsheet, null); final int cFullFillWidth = 10000; layout.setMinimumWidth(cFullFillWidth); TextView mContent = (TextView) layout.findViewById(R.id.content); TextView mCancel = (TextView) layout.findViewById(R.id.cancel); mContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub actionSheetSelected.onClick(0); dlg.dismiss(); } }); mCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub actionSheetSelected.onClick(1); dlg.dismiss(); } }); Window w = dlg.getWindow(); WindowManager.LayoutParams lp = w.getAttributes(); lp.x = 0; final int cMakeBottom = 0; lp.y = cMakeBottom; lp.gravity = Gravity.CENTER; dlg.onWindowAttributesChanged(lp); dlg.setCanceledOnTouchOutside(false); if (cancelListener != null) dlg.setOnCancelListener(cancelListener); dlg.setContentView(layout); dlg.show(); return dlg; } }4.MainActivity
public class MainActivity extends Activity implements OnActionSheetSelected, OnCancelListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.show).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub ActionSheet.showSheet(MainActivity.this, MainActivity.this, MainActivity.this); } }); } @Override public void onClick(int whichButton) { // TODO Auto-generated method stub switch (whichButton) { case 0: showToast("確定"); break; case 1: showToast("取消"); break; default: break; } } @Override public void onCancel(DialogInterface dialog) { // TODO Auto-generated method stub showToast("取消"); } private void showToast(CharSequence charSequence) { Toast.makeText(this, charSequence, Toast.LENGTH_SHORT).show(); } }
源碼下載地址
安卓右鍵工具,集成dex轉jar,二進制xml查看,apk相關信息查詢,apk圖標提取,apk優化,手機屏幕截圖,安裝卸載,簽名,反編譯和回編譯等功能,方便快捷,開發者們
ReactNative的發展已經進入了很多開發者視野,作為一名原生開發者更是對 RN 充滿了無限的好奇和期待,本節將詳細講述如何將一個原生的 Android App 項目
Android listView 繪制表格效果圖:二,創建步驟:1,創建布局:activity_main中的布局:<LinearLayout xmlns
理解android視圖 對於android設備我們所看到的區域其實和它在底層的繪制有著很大的關系,很多時候我們都只關心我們所看到的,那麼在底層一點它到底是怎麼樣的一個東西