iOS UIScrollView 垂直滾動佈局:layoutScrollImages 修改 Y 軸佈局
原水平滾動代碼 CGFloat curXLoc = 0; for (UIView *view in subviews) { if ([view isKi
Android 程序安裝 APK:Intent.ACTION_VIEW 正確 MIME 類型
錯誤代碼 intent.setData(Uri.parse(path)); intent.setType(application/android.com.app
Android AsyncTask onPostExecute 不執行:主線程阻塞導致回調無法分發
問題代碼 public void click() { new Load().execute(); while (wait) { ; } // 主
iOS Button 圖片互換:currentImage 屬性直接賦值
問題代碼 [btn2 setImage:[UIImage imageNamed:btn1.currentBackgroundImage] forState:UI
Android 屏幕旋轉音樂播放不中斷:Service 承載播放邏輯
問題 Activity 中直接創建 MediaPlayer,旋轉屏幕導致 Activity 重建,音樂重播或停止。 解決架構:Service + MediaP
Android Intent 啟動第二個 Activity:Manifest 註冊不可少
問題現象 點擊按鈕 startActivity(intent) 無反應,無崩潰日誌,第二個 Activity 不顯示。 原因 AndroidManifest.
Android AsyncTask 結果回調 Activity:接口回調模式實現解耦
定義回調接口 public interface AsyncCallback { void onTaskComplete(String result);
Android ListView 指定項背景顏色:自定義 Adapter 重寫 getView
問題 使用 ArrayAdapter 直接綁定數據,需根據位置動態設置項目背景色。 方案:繼承 ArrayAdapter 重寫 getView public
Android 訪問媒體庫播放音樂:MediaStore 查詢與 Intent 播放
查詢所有音頻文件 public MusicFile[] readAllMusic(Context context) { Cursor cursor =
Android ListView 分割線顏色與高度:XML 屬性直接設置
XML 設置 <ListView android:id=@+id/list android:layout_width=match_pare
Android XML 解析錯誤:缺少 xmlns:android 命名空間聲明
錯誤信息 Error parsing XML: unbound prefix 問題代碼 <?xml version=1.0 encoding=utf-
Android 列出 SD 卡目錄文件:File.listFiles 配合 ArrayAdapter
核心代碼 List items = new ArrayList<>(); List paths = new ArrayList<>(); File dir =
Android ListView 圓角邊框:Shape Drawable 實現
Drawable 資源 (res/drawable/list_rounded.xml) <shape xmlns:android=https://sche
Android NDK 構建共享庫:Android.mk 與 Application.mk 配置指南
目錄結構 jni/ Android.mk Application.mk mylib/ include/ src/ Andro
Android px 與 dp 互轉工具類:基於 DisplayMetrics.density
核心公式 px = dp * density dp = px / density density = dpi / 160 (如 mdpi=1.0,
Android 視圖右對齊:RelativeLayout 或 gravity 正確配置
問題代碼 <LinearLayout android:orientation=horizontal ...> <ImageView .
Android XML 定義下劃線文本:String Resource 支持 HTML 標簽
XML 字符串資源 <resources> <string name=underlined_text>This is an &l
Android 判斷兩個 Context 是否相同:比較 Class 對象
方法 public boolean isSameContext(Context c1, Context c2) { return c1 != null