最近在项目中有使用到搜索框的地方,由于其样式要求与iOS的UISearchBar的风格一致.默认情况下,搜索图标和文字是居中的,在获取焦点的时候,图标和文字左移.但是在Android是并没有这样的控件(可能见识少,并不知道有).通常情况下我们使用组合控件,使用ReleativeLayout或者FrameLayout来实现.此篇并不是使用上述方法实现,其核心是继承系统EditText,重写onDraw方法,来改变默认的左上右下的drawable,实现平移到中间位置.这里暂时只实现了drawable…
我们在开发App的时候有时候碰到多个界面有一个共同点的时候,比如,都有相同的TitleBar,并且TitleBar可以设置显示的文字.TitleBar上的点击事件,如果给每一个Activity都写一遍TitleBar是一件非常费事的事情,这个时候我们就可以重写一个Activity基类,让其他有相同点的Activity来继承这个类,从而省去了很多的重复不必要的工作.提高了效率. 如图: 两个界面拥有共同的特点,有一个我们自己定义的TitleBar,这个TitleBar属于我们自定义的基类BaseA…
C++自定义String字符串类 实现了各种基本操作,包括重载+号实现String的拼接 findSubStr函数,也就是寻找目标串在String中的位置,用到了KMP字符串搜索算法. #include <iostream> #include <cstring> using namespace std; class String; class Data{ // 抽象基类Data public: virtual const int compareTo(const String&…
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <!--注…
package com.dwtedx.qq.view; import android.annotation.SuppressLint; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.ContextMenu; import android.view.MenuItem; import android…
摘要: 小巧简洁的原生搜索框,漂亮而易用,如果我们的应用没有特殊需求,都可以使用它. iOS中UISearchBar(搜索框)使用总结 初始化:UISearchBar继承于UIView,我们可以像创建View那样创建searchBar     UISearchBar * bar = [[UISearchBar alloc]initWithFrame:CGRectMake(20, 100, 250, 40)];     [self.view addSubview:bar]; @property(n…
在iOS 8.0以上版本中, 我们可以使用UISearchController来非常方便地在UITableView中添加搜索框. 而在之前版本中, 我们还是必须使用UISearchBar + UISearchDisplayController的组合方式. 添加UISearchController属性: @property(strong, nonatomic) UISearchController *searchController; @property(strong, nonatomic) NS…
由于项目的需要,系统的弹出框已经不能满足我们的需求,我们需要各式各样的弹出框,这时就需要我们去自定义弹出框了. 新建布局文件 dialog_layout.xml,将下面内容复制进去 <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:lay…
<RadioButton android:id="@+id/rb_never" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:button="@null" android:checked=&qu…
Android为程序的搜索功能提供了统一的搜索接口,search dialog和search widget,这里介绍search dialog使用.search dialog 只能为于activity窗口的上方.下面以点击EditText输入框启动search dialog搜索框为例:效果如下 实现步骤: 1. 新建searchable.xml配置文件,放在res/xml目录下.searchable.xml用于配置搜索框相关属性,配置文件内容为: <?xml version="1.0&qu…