Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
development
Commits
1d6d833c
Commit
1d6d833c
authored
10 years ago
by
Chris Banes
Browse files
Options
Download
Email Patches
Plain Diff
TextInputLayout and Snackbar demos
Change-Id: I8de5e4d21528225f9688e8d42c73f51ce42bc8b8
parent
0536cbb4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
414 additions
and
0 deletions
+414
-0
samples/SupportDesignDemos/AndroidManifest.xml
samples/SupportDesignDemos/AndroidManifest.xml
+26
-0
samples/SupportDesignDemos/res/layout/design_snackbar.xml
samples/SupportDesignDemos/res/layout/design_snackbar.xml
+61
-0
samples/SupportDesignDemos/res/layout/design_snackbar_with_fab.xml
...upportDesignDemos/res/layout/design_snackbar_with_fab.xml
+69
-0
samples/SupportDesignDemos/res/layout/design_text_input.xml
samples/SupportDesignDemos/res/layout/design_text_input.xml
+66
-0
samples/SupportDesignDemos/res/values/strings.xml
samples/SupportDesignDemos/res/values/strings.xml
+15
-0
samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarUsage.java
.../example/android/support/design/widget/SnackbarUsage.java
+91
-0
samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithFloatingActionButton.java
...pport/design/widget/SnackbarWithFloatingActionButton.java
+37
-0
samples/SupportDesignDemos/src/com/example/android/support/design/widget/TextInputLayoutUsage.java
...e/android/support/design/widget/TextInputLayoutUsage.java
+49
-0
No files found.
samples/SupportDesignDemos/AndroidManifest.xml
View file @
1d6d833c
...
...
@@ -54,5 +54,31 @@
</intent-filter>
</activity>
<activity
android:name=
".widget.TextInputLayoutUsage"
android:label=
"@string/design_text_input"
android:theme=
"@style/Theme.AppCompat.Light.DarkActionBar"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
</intent-filter>
</activity>
<activity
android:name=
".widget.SnackbarUsage"
android:label=
"@string/design_snackbar_basic"
android:theme=
"@style/Theme.AppCompat.Light.DarkActionBar"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"com.example.android.support.design.SAMPLE_CODE"
/>
</intent-filter>
</activity>
<activity
android:name=
".widget.SnackbarWithFloatingActionButton"
android:label=
"@string/design_snackbar_fab"
android:theme=
"@style/Theme.AppCompat.Light.DarkActionBar"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"com.example.android.support.design.SAMPLE_CODE"
/>
</intent-filter>
</activity>
</application>
</manifest>
This diff is collapsed.
Click to expand it.
samples/SupportDesignDemos/res/layout/design_snackbar.xml
0 → 100644
View file @
1d6d833c
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<android.support.design.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/content_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:padding=
"16dp"
android:orientation=
"vertical"
>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_short"
android:onClick=
"showShort"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_short_action"
android:onClick=
"showAction"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_long"
android:onClick=
"showLong"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_long_action"
android:onClick=
"showLongAction"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_long_long_action"
android:onClick=
"showLongLongAction"
/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
samples/SupportDesignDemos/res/layout/design_snackbar_with_fab.xml
0 → 100644
View file @
1d6d833c
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<android.support.design.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/content_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:padding=
"16dp"
android:orientation=
"vertical"
>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_short"
android:onClick=
"showShort"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_short_action"
android:onClick=
"showAction"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_long"
android:onClick=
"showLong"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_long_action"
android:onClick=
"showLongAction"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/snackbar_show_long_long_action"
android:onClick=
"showLongLongAction"
/>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_gravity=
"bottom|end"
android:layout_margin=
"16dp"
android:src=
"@drawable/abc_ic_ab_back_mtrl_am_alpha"
android:clickable=
"true"
/>
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
samples/SupportDesignDemos/res/layout/design_text_input.xml
0 → 100644
View file @
1d6d833c
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:padding=
"16dp"
>
<android.support.design.widget.TextInputLayout
android:id=
"@+id/input_username"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:errorEnabled=
"true"
>
<EditText
android:id=
"@+id/edit_username"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"@string/form_username"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id=
"@+id/input_email"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
app:errorEnabled=
"true"
>
<EditText
android:id=
"@+id/edit_email"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"@string/form_email"
/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/show_error"
android:onClick=
"showError"
/>
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/clear_error"
android:onClick=
"clearError"
/>
</LinearLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
samples/SupportDesignDemos/res/values/strings.xml
View file @
1d6d833c
...
...
@@ -19,6 +19,8 @@
<string
name=
"design_fab"
>
Floating Action Button/Basic
</string>
<string
name=
"design_tabs_basic"
>
TabLayout/Usage
</string>
<string
name=
"design_text_input"
>
Text Input
</string>
<string
name=
"fab_size_normal"
>
Normal size
</string>
<string
name=
"fab_size_mini"
>
Mini size
</string>
...
...
@@ -30,4 +32,17 @@
<string
name=
"add_tab"
>
Add tab
</string>
<string
name=
"remove_tab"
>
Remove tab
</string>
<string
name=
"form_username"
>
Username
</string>
<string
name=
"form_email"
>
Email address
</string>
<string
name=
"show_error"
>
Show error
</string>
<string
name=
"clear_error"
>
Clear error
</string>
<string
name=
"design_snackbar_basic"
>
Snackbar/Usage
</string>
<string
name=
"design_snackbar_fab"
>
Snackbar/Coordinated with FAB
</string>
<string
name=
"snackbar_show_short"
>
Snackbar (short message)
</string>
<string
name=
"snackbar_show_long"
>
Snackbar (long message)
</string>
<string
name=
"snackbar_show_short_action"
>
Show (short message + action)
</string>
<string
name=
"snackbar_show_long_action"
>
Show (long message + action)
</string>
<string
name=
"snackbar_show_long_long_action"
>
Show (long message + long action)
</string>
</resources>
This diff is collapsed.
Click to expand it.
samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarUsage.java
0 → 100644
View file @
1d6d833c
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.example.android.support.design.widget
;
import
com.example.android.support.design.R
;
import
android.os.Bundle
;
import
android.support.design.widget.Snackbar
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Toast
;
/**
* This demonstrates idiomatic usage of the Floating Action Button
*/
public
class
SnackbarUsage
extends
AppCompatActivity
{
private
ViewGroup
mContentView
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
getLayoutId
());
mContentView
=
(
ViewGroup
)
findViewById
(
R
.
id
.
content_view
);
}
protected
int
getLayoutId
()
{
return
R
.
layout
.
design_snackbar
;
}
public
void
showShort
(
View
view
)
{
Snackbar
.
make
(
mContentView
,
"Short snackbar message"
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
public
void
showAction
(
View
view
)
{
Snackbar
.
make
(
mContentView
,
"Short snackbar message"
,
Snackbar
.
LENGTH_SHORT
)
.
setAction
(
"Action"
,
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Toast
.
makeText
(
SnackbarUsage
.
this
,
"Snackbar Action pressed"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}).
show
();
}
public
void
showLong
(
View
view
)
{
Snackbar
.
make
(
mContentView
,
"Long snackbar message which wraps onto another line and"
+
"makes the Snackbar taller"
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
public
void
showLongAction
(
View
view
)
{
Snackbar
.
make
(
mContentView
,
"Long snackbar message which wraps onto another line and"
+
"makes the Snackbar taller"
,
Snackbar
.
LENGTH_SHORT
)
.
setAction
(
"Action"
,
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Toast
.
makeText
(
SnackbarUsage
.
this
,
"Snackbar Action pressed"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}).
show
();
}
public
void
showLongLongAction
(
View
view
)
{
Snackbar
.
make
(
mContentView
,
"Long snackbar message which wraps onto another line and"
+
"makes the Snackbar taller"
,
Snackbar
.
LENGTH_SHORT
)
.
setAction
(
"Action which wraps"
,
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Toast
.
makeText
(
SnackbarUsage
.
this
,
"Snackbar Action pressed"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}).
show
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
samples/SupportDesignDemos/src/com/example/android/support/design/widget/SnackbarWithFloatingActionButton.java
0 → 100644
View file @
1d6d833c
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.example.android.support.design.widget
;
import
com.example.android.support.design.R
;
import
android.os.Bundle
;
import
android.support.design.widget.Snackbar
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
import
android.view.ViewGroup
;
/**
* This demonstrates idiomatic usage of the Floating Action Button
*/
public
class
SnackbarWithFloatingActionButton
extends
SnackbarUsage
{
@Override
protected
int
getLayoutId
()
{
return
R
.
layout
.
design_snackbar_with_fab
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
samples/SupportDesignDemos/src/com/example/android/support/design/widget/TextInputLayoutUsage.java
0 → 100644
View file @
1d6d833c
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.example.android.support.design.widget
;
import
com.example.android.support.design.R
;
import
android.os.Bundle
;
import
android.support.design.widget.TextInputLayout
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
/**
* This demonstrates idiomatic usage of {@code TextInputLayout}
*/
public
class
TextInputLayoutUsage
extends
AppCompatActivity
{
private
TextInputLayout
mUsernameInputLayout
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
design_text_input
);
mUsernameInputLayout
=
(
TextInputLayout
)
findViewById
(
R
.
id
.
input_username
);
}
public
void
showError
(
View
view
)
{
mUsernameInputLayout
.
setError
(
"Some unknown error has occurred"
);
}
public
void
clearError
(
View
view
)
{
mUsernameInputLayout
.
setError
(
null
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment