GithubHelp home page GithubHelp logo

gongqing / showbuttonlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xsy2015/showbuttonlayout

0.0 0.0 0.0 150 KB

ShowButtonLayout,you can display any number of Button, wrap, can be used for hot search, uncertain number of Button(标签、热门搜索、搜索历史)

Java 100.00%

showbuttonlayout's Introduction

1.效果预览


2.如何使用该开源库


Gradle:

Step 1. 添加JitPack仓库

在当前项目的根目录下的 build.gradle 文件中添加如下内容:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
Step 2. 添加项目依赖
dependencies {
	        compile 'com.github.xsy2015:ShowButtonLayout:v1.0.1'
	}
Step 3. 在xml文件中引用
<com.xsy.lib.ShowButtonLayout
        android:id="@+id/mShowBtnLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
Step 4.设置数据
 for (int i = 0; i < hotWords.length; i++) {
            TextView view = (TextView) LayoutInflater.from(this).inflate(R.layout.hot_search_tv, mShowBtnLayout, false);
            view.setText(hotWords[i]);
            view.setTag(hotWords[i]);
            view.setOnClickListener(new View.OnClickListener() {//设置点击事件
                @Override
                public void onClick(View view) {
                    String keyword = (String) view.getTag();
                    Toast.makeText(MainActivity.this,keyword,Toast.LENGTH_LONG).show();
                }
            });
            mShowBtnLayout.addView(view);//添加到该view中
        }

showbuttonlayout's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.