Skip to content

Commit

Permalink
Merge pull request #102 from ganfra/chore/empty-array-sample
Browse files Browse the repository at this point in the history
Chore/empty array sample
  • Loading branch information
mdumrauf committed Sep 20, 2017
2 parents 4e65cd0 + 664f2c1 commit 25c74f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class MainActivity extends ActionBarActivity {
MaterialSpinner spinner4;
MaterialSpinner spinner5;
MaterialSpinner spinner6;
MaterialSpinner spinner7;

private boolean shown = false;

Expand All @@ -41,42 +42,48 @@ protected void onCreate(Bundle savedInstanceState) {
initSpinnerMultiline();
initSpinnerScrolling();
initSpinnerHintAndCustomHintView();
initEmptyArray();

}

private void initSpinnerHintAndCustomHintView() {
spinner6 = (MaterialSpinner) findViewById(R.id.spinner6);
spinner6 = findViewById(R.id.spinner6);
spinner6.setAdapter(adapter);
spinner4.setHint("Select an item");
}

private void initSpinnerHintAndFloatingLabel() {
spinner1 = (MaterialSpinner) findViewById(R.id.spinner1);
spinner1 = findViewById(R.id.spinner1);
spinner1.setAdapter(adapter);
spinner1.setPaddingSafe(0, 0, 0, 0);
}

private void initSpinnerOnlyHint() {
spinner2 = (MaterialSpinner) findViewById(R.id.spinner2);
spinner2 = findViewById(R.id.spinner2);
}

private void initSpinnerNoHintNoFloatingLabel() {
spinner3 = (MaterialSpinner) findViewById(R.id.spinner3);
spinner3 = findViewById(R.id.spinner3);
spinner3.setAdapter(adapter);
}

private void initSpinnerMultiline() {
spinner4 = (MaterialSpinner) findViewById(R.id.spinner4);
spinner4 = findViewById(R.id.spinner4);
spinner4.setAdapter(adapter);
spinner4.setHint("Select an item");
}

private void initSpinnerScrolling() {
spinner5 = (MaterialSpinner) findViewById(R.id.spinner5);
spinner5 = findViewById(R.id.spinner5);
spinner5.setAdapter(adapter);
spinner5.setHint("Select an item");
}

private void initEmptyArray() {
String[] emptyArray = {};
spinner7 = findViewById(R.id.spinner7);
spinner7.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, emptyArray));
}

public void activateError(View view) {
if (!shown) {
Expand Down
19 changes: 12 additions & 7 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_arrowColor="#0000FF"
app:ms_arrowSize="16dp"
Expand All @@ -24,7 +24,7 @@

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinner2"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_enableErrorLabel="false"
app:ms_enableFloatingLabel="false"
Expand All @@ -33,27 +33,27 @@

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinner3"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_enableErrorLabel="false"
app:ms_enableFloatingLabel="false" />

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinner4"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_alignLabels="false"
app:ms_baseColor="@color/spinner_base_color"
app:ms_multiline="false" />

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinner5"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinner6"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ms_enableErrorLabel="false"
app:ms_enableFloatingLabel="false"
Expand All @@ -62,8 +62,13 @@
app:ms_hint="hint"
app:ms_hintColor="#0000FF" />

<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/spinner7"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<Button
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Show/hide error"
android:onClick="activateError" />
Expand Down

0 comments on commit 25c74f2

Please sign in to comment.