原创 Python中{0:2d} {1:3d} {2:4d}'.format(x, x * x, x * x * x)理解

代碼 for x in range(1, 11): print('{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x)) 結果 1 1 1 2 4 8 3

原创 python實現批量文件重命名

代碼實現 import os #path爲批量文件的文件夾的路徑 path = 'd:\\renamefolder' #文件夾中所有文件的文件名 file_names = os.listdir(path) #外循環遍歷

原创 python實現大量圖片重命名

代碼實現 # -*- coding:utf8 -*- import os class BatchRename(): ''' 批量重命名文件夾中的圖片文件 ''' def __init__(self): sel

原创 Python報錯can only concatenate str (not "int") to str

// 代碼 thisset = set(("Google", "Running", "Taobao")) print("length = "+ len(thisset)) // 報錯 Traceback (most recent

原创 python基礎練習(二)

代碼 # Fibonacci series: 斐波納契數列 # 兩個元素的總和確定了下一個數 a,b=0,1 while b <10: #print(b) #橫屏輸出 print(b,end=",")

原创 python報錯 TypeError: 'str' object is not callable

在運行python測試程序時,出現以下報錯 Traceback (most recent call last): File "D:\python\hello.py", line 233, in <module> n =

原创 代碼裏設置TextView的color, 使用selector顏色選擇器

如果是在xml文件裏,直接使用selector即可 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.co

原创 Android事件分發

View相關方法 @Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()){

原创 Android Button實現上圖下文字 drawableTop 屬性

需求 需要實現上面是圖片,下面是文字的空間,最簡單的辦法是直接用Button實現,不需要自定義。 實現 xml裏實現 在xml佈局文件中直接寫 //xml <Button android:id="

原创 Android實現檢測3s內客戶無操作&&界面長按3s彈出隱藏按鈕

界面長按3s彈出隱藏按鈕 在界面裏重寫onTouchEvent方法,當隱藏按鈕不可見時,長按ACTION_DOWN,延時啓動隱藏按鈕,當檢測到其它Action,取消顯示隱藏按鈕。 @Override public boo

原创 Android如何使佈局中圖(ImageButton)和文字(TextView)同時獲得press和selected狀態

問題 佈局中有圖片和文字,希望按下時,同時有press狀態,並且同時能有select狀態。 實現 需要注意的是,子view需要調用這3個屬性,使其不獲得焦點,所有狀態都給佈局LinearLayout,所有的view都需加上對應的

原创 Android showSoftInput概率性彈不出鍵盤

Android中調用系統鍵盤代碼: InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INP

原创 Android 9 Cleartext HTTP traffic to xxx not permitted

問題 Android 9 訪問網絡時報錯 Cleartext HTTP traffic to xxx not permitted 據說是最新版沒有Http訪問權限 解決1 把代碼裏的網址http開頭的換成https 方法HttpU

原创 Android實現textView倒影效果ReflectTextView

代碼轉載自https://github.com/Dean1990/ReflectTextView by Dean1990 效果 要實現帶倒影效果的textview,效果如下 有2種方法,一種是如果是隻有數字和字母,讓設計切

原创 AS運行project報please select android sdk

描述 今天運行AS的時候突然報java.io.IOException: Could not delete path問題, 手動clean project也不管用,一直報這個錯。 在as terminal輸入gradlew clea