Android EditText 設置提示文字:使用 xml android:hint 屬性
最簡單方法 <EditText android:id=@+id/editText_user android:hint=用戶名 a
Android TextView 點擊 @用戶 跳轉執行兩次:onTouchEvent ACTION_DOWN/UP 處理邏輯修正
問題原因 自定義 TextView 重寫 onTouchEvent 時,手動構造 ACTION_UP 事件導致 MovementMethod 處理兩次點擊,觸發
iOS 多個 UIButton 統一管理:放入 UIView 容器
做法 創建容器視圖:UIView *btnContainer = [[UIView alloc] initWithFrame:...]; 添加按鈕:[btnC
iOS 解析 HTML 提取 BinarySecurityToken:簡單字符串截取
代碼 NSString *html = ...; // 響應字符串 NSString *startTag = @; NSString *endTag = @;
Android ListView 嵌套 GridView 點擊事件穿透:requestDisallowInterceptTouchEvent
問題 GridView 空白區域點擊不觸發 ListView OnItemClickListener。 解決 GridView 設置 android:desc
iOS 獲取螢幕尺寸:UIScreen mainScreen bounds
正確代碼 CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat width = screen
iOS ARC 下 NSNotificationCenter 移除觀察者:dealloc 中調用
規則 通知中心**不持有**觀察者強引用 (弱引用),觀察者釋放時**必須**主動移除,否則發送通知時向已釋放對象發消息導致崩潰。 標準做法 - (void)
iOS UIWebView 加載 .doc/.docx 文件崩潰:路徑獲取方式修正
問題代碼 NSString *path = [[NSBundle mainBundle] pathForResource:@C9 ofType:@doc];
iOS NSTimeInterval 獲取當日零點時間戳
代碼 NSCalendar *cal = [NSCalendar currentCalendar]; NSDate *now = [NSDate date];
iOS 字符串移除所有數字:正則表達式替換
代碼 NSString *str = @hb4hbb543bt3g; NSString *result = [str stringByReplacingOcc
Android 短信查詢區分收發:type 字段判斷
字段含義 type = 1 : 接收 (Inbox) type = 2 : 發送 (Sent) type = 3 : 草稿 type = 4 : 發送失敗 t
iOS NSDate timeIntervalSinceDate 返回 0:格式化輸出類型錯誤
問題代碼 0 修正 NSLog(@%f, [date1 timeIntervalSinceDate:date2]); // %f 輸出 double //
Android EditText 獲取光標位置:getSelectionStart
方法 0) { char charBefore = editText.getText().charAt(cursorPos - 1); } 監聽變化
iOS UITableViewCell 子視圖裁剪:設置 layer.cornerRadius 配合 clipsToBounds
問題 Cell 設置 clipsToBounds = YES 但添加的 ImageView 圓角不生效。 原因 clipsToBounds 裁剪的是 **自身
iOS ARC 環境下釋放 calloc 內存:必須手動 free
原則 ARC 僅管理 Objective-C 對象 (id 類型)。C 語言分配的內存 (malloc, calloc, realloc) **不受 ARC 管
Android 使用 ContentProvider 鎖定短信:locked 字段更新
代碼 private void lockMessage(long msgId, boolean lock, String type) { Uri bas
Android 讀取短信會話:按 thread_id 查詢具體消息
正確流程 查詢會話列表:content://mms-sms/conversations/ 獲取 thread_id。 按 thread_id 查詢具體消息:
Java List 原始類型警告:添加泛型參數消除 @SuppressWarnings
警告代碼 List list = sn.getSiteInfo(); // 原始類型 List 修正 List list = sn.getSiteInfo()