- Author:Carson_Ho
- Summary
a simple & useful Android DIY View for Searching function
Carson_Ho Github:SearchLayout,welcome Star !
Searching & High Diy style
- Fresh & concise style
- Easy to use
- Secondary Programming costs are low
There are two ways to import Library:
-
- For Gradle build.Gradle
dependencies {
compile 'com.carson_ho:SearchLayout:1.0.1'
}
-
- For Maven pom.xml
<dependency>
<groupId>com.carson_ho</groupId>
<artifactId>SearchLayout</artifactId>
<version>1.0.1</version>
<type>pom</type>
</dependency>
- Attributes Description:
- Use examples
activity_main.xml
<scut.carson_ho.searchview.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:textSizeSearch="5dp"
app:textColorSearch="#3F51B5"
app:textHintSearch="输入查询关键字"
app:searchBlockHeight="150"
app:searchBlockColor="#ffffff"
/>
MainActivity.java
// 1. 初始化搜索框变量
private SearchView searchView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 2. 绑定视图
setContentView(R.layout.activity_search);
// 3. 绑定组件
searchView = (SearchView) findViewById(R.id.search_view);
// 4. 设置点击搜索按键后的操作(通过回调接口)
// 参数 = 搜索框输入的内容
searchView.setOnClickSearch(new ICallBack() {
@Override
public void SearchAciton(String string) {
System.out.println("我收到了" + string);
}
});
// 5. 设置点击返回按键后的操作(通过回调接口)
searchView.setOnClickBack(new bCallBack() {
@Override
public void BackAciton() {
finish();
}
});
}
}
SearchLayout is available under the MIT license.
Before you open an issue or create a pull request, please read Contributing Guide first.
2017-08-11 v1.0.0 :add base function
- ID:Carson_Ho
- 简介:CSDN签约作者、简书推荐作者、稀土掘金专栏作者
- E - mail:[email protected]
- Github:https://github.com/Carson-Ho
- CSDN:http://blog.csdn.net/carson_ho
- 简书:http://www.jianshu.com/u/383970bef0a0
- 稀土掘金:https://juejin.im/user/58d4d9781b69e6006ba65edc