Skip to content

icetum15/RadioButtonView

 
 

Repository files navigation

RadioButtonView

一个简单单选按钮。

SnapShot


How To

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file

	allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

Step 2. Add the dependency

	dependencies {
	        compile 'com.github.pwcong:RadioButtonView:v1.0.0'
	}


Usage

Step 1. Add it in Layout

    <me.pwcong.radiobuttonview.view.RadioButtonView
        android:id="@+id/rbv_1"
        android:layout_width="500dp"
        android:layout_height="100dp" 
        app:frameColor="#FF4081"
        app:textColor="#FFFFFF"
        app:strokeWidth="6dp"
        app:margin="12dp"/>
        

Step 2. Initialize it

      protected void onCreate(Bundle savedInstanceState) {
      
        ...

        rbv = (RadioButtonView) findViewById(R.id.rbv_1);
        
        rbv.setOptions(getArrayList());
        
        rbv.setOnRadioButtonChangedListener(new RadioButtonView.OnRadioButtonChangedListener() {
            @Override
            public void onRadioButtonChanged(String option, int index) {

              //Todo

            }
        });
        
      }

      private ArrayList<String> getArrayList(){
      
        ...
        
      }

Here are the attributes of RadioButtonView

    <declare-styleable name="RadioButtonView">

        <attr name="margin" format="dimension"/>
        <attr name="strokeWidth" format="dimension"/>
        <attr name="frameColor" format="color"/>
        <attr name="textColor" format="color"/>

    </declare-styleable>

About

单选按钮。

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%