Coder Social home page Coder Social logo

hindicatordialog's Introduction

引入

  • 1.0 将下面代码添加到项目的根目录的build.gradle:
allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}
  • 2.0 将下面代码添加到app目录的build.gradle:
dependencies { 
     compile 'com.github.huangbryant210707:HIndicatorDialog:2.2.0'
}

使用

  • 1.0 默认的使用方法(使用默认的Adpater)
dialog = new HIndicatorBuilder(this)
                .width(200)  
                .height(-1)  
                .arrowDirection(HIndicatorBuilder.TOP)  
                .bgColor(Color.parseColor("#999898"))  
                .gravity(HIndicatorBuilder.GRAVITY_LEFT)  
                .radius(8) 
                .arrowRectage(0.2f)  
                .data(mList)
                .clickListener(this)
                .enableTouchOutside(false)
                .create();
        dialog.show(view); 
        
 @Override
    public void OnItemClick(int position) {
        dialog.dismiss();
        Log.e("----", mList.get(position));
    }
  • 2.0 自定义Adpater
HIndicatorDialog dialog = new HIndicatorBuilder(this)
                .width(200)  
                .height(-1)  
                .ArrowDirection(HIndicatorBuilder.TOP)  
                .bgColor(Color.parseColor("#999898"))  
                .gravity(HIndicatorBuilder.GRAVITY_LEFT)   
                .radius(8) 
                .ArrowRectage(0.2f)  
                .layoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false))
                .dimEnabled(false)
                .adapter(new MyAdapter())
                .create();
        dialog.setCanceledOnTouchOutside(true);
        dialog.show(spinner);
        
public class MyAdapter extends BaseHIndicatorAdapter {
        @Override
        public void onBindView(BaseViewHolder holder, int position) {
            TextView tv = holder.getView(R.id.item_tv);
            tv.setText(mList.get(position));
            tv.setCompoundDrawablesWithIntrinsicBounds(mICons.get(position), 0, 0, 0);

            if (position == mList.size() - 1) {
                holder.setVisibility(R.id.item_line, BaseViewHolder.GONE);
            } else {
                holder.setVisibility(R.id.item_line, BaseViewHolder.VISIBLE);
            }
        }

        @Override
        public int getLayoutID(int position) {
            return R.layout.hindicator_item_layout;
        }

        @Override
        public boolean clickable() {
            return true;
        }

        @Override
        public void onItemClick(View v, int position) {

        }

        @Override
        public int getItemCount() {
            return mList.size();
        }
    }

hindicatordialog's People

Contributors

huang2177 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar ludy avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

耗子 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

zhaozhen0201

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.