am 7cc27946: am c3716abd: Merge "Add some samples for AppCompat\'s styled widgets" into lmp-mr1-ub-dev
* commit '7cc27946961192ebd0c1a3b78c7674f3512625db': Add some samples for AppCompat's styled widgets
This commit is contained in:
@@ -213,6 +213,33 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".app.AppCompatWidgetsButtons"
|
||||||
|
android:label="@string/appcompat_widgets_buttons"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".app.AppCompatWidgetsSpinners"
|
||||||
|
android:label="@string/appcompat_widgets_spinners"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".app.AppCompatWidgetsTextInput"
|
||||||
|
android:label="@string/appcompat_widgets_text_input"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".app.ToolbarUsage"
|
<activity android:name=".app.ToolbarUsage"
|
||||||
android:label="@string/toolbar_usage"
|
android:label="@string/toolbar_usage"
|
||||||
android:theme="@style/Theme.Custom.NoActionBar">
|
android:theme="@style/Theme.Custom.NoActionBar">
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<android.support.v7.widget.SwitchCompat
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="Switch"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="CheckBox"/>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radiobutton_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="RadioButton"/>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radiobutton_2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="RadioButton"/>
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Button"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Button (small)"
|
||||||
|
style="@style/Widget.AppCompat.Button.Small"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Button (borderless)"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Button (borderless + colored)"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless.Colored"/>
|
||||||
|
|
||||||
|
<RatingBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?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"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="EditText"/>
|
||||||
|
|
||||||
|
<AutoCompleteTextView
|
||||||
|
android:id="@+id/widgets_autocompletetextview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="AutoCompleteTextView"/>
|
||||||
|
|
||||||
|
<MultiAutoCompleteTextView
|
||||||
|
android:id="@+id/widgets_multiautocompletetextview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="MultiAutoCompleteTextView"/>
|
||||||
|
|
||||||
|
<CheckedTextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="CheckedTextView"
|
||||||
|
android:checked="true"
|
||||||
|
android:checkMark="?android:listChoiceIndicatorMultiple"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?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"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/widgets_spinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/widgets_spinner_underlined"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/Widget.AppCompat.Spinner.Underlined"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
@@ -57,6 +57,9 @@
|
|||||||
<string name="action_bar_settings_action_provider_no_handling">Handling in onOptionsItemSelected avoided</string>
|
<string name="action_bar_settings_action_provider_no_handling">Handling in onOptionsItemSelected avoided</string>
|
||||||
<string name="action_bar_with_navigation_drawer">AppCompat/Action Bar/Navigation Drawer Toggle</string>
|
<string name="action_bar_with_navigation_drawer">AppCompat/Action Bar/Navigation Drawer Toggle</string>
|
||||||
<string name="action_bar_preferences">AppCompat/Action Bar/Preferences</string>
|
<string name="action_bar_preferences">AppCompat/Action Bar/Preferences</string>
|
||||||
|
<string name="appcompat_widgets_buttons">AppCompat/Widgets/Buttons</string>
|
||||||
|
<string name="appcompat_widgets_spinners">AppCompat/Widgets/Spinners</string>
|
||||||
|
<string name="appcompat_widgets_text_input">AppCompat/Widgets/Text Input</string>
|
||||||
|
|
||||||
<string name="action_bar_search">Search</string>
|
<string name="action_bar_search">Search</string>
|
||||||
<string name="action_bar_add">Add</string>
|
<string name="action_bar_add">Add</string>
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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.supportv7.app;
|
||||||
|
|
||||||
|
import com.example.android.supportv7.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This demonstrates the styled {@link android.widget.Button} widgets in AppCompat.
|
||||||
|
*/
|
||||||
|
public class AppCompatWidgetsButtons extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.appcompat_widgets_buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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.supportv7.app;
|
||||||
|
|
||||||
|
import com.example.android.supportv7.Cheeses;
|
||||||
|
import com.example.android.supportv7.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This demonstrates the styled {@link android.widget.Spinner} widgets in AppCompat.
|
||||||
|
*/
|
||||||
|
public class AppCompatWidgetsSpinners extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.appcompat_widgets_text_spinners);
|
||||||
|
|
||||||
|
// Fetch the Spinners and set an adapter
|
||||||
|
Spinner spinner = (Spinner) findViewById(R.id.widgets_spinner);
|
||||||
|
spinner.setAdapter(new ArrayAdapter<>(this,
|
||||||
|
R.layout.support_simple_spinner_dropdown_item, Cheeses.sCheeseStrings));
|
||||||
|
|
||||||
|
spinner = (Spinner) findViewById(R.id.widgets_spinner_underlined);
|
||||||
|
spinner.setAdapter(new ArrayAdapter<>(this,
|
||||||
|
R.layout.support_simple_spinner_dropdown_item, Cheeses.sCheeseStrings));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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.supportv7.app;
|
||||||
|
|
||||||
|
import com.example.android.supportv7.Cheeses;
|
||||||
|
import com.example.android.supportv7.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AutoCompleteTextView;
|
||||||
|
import android.widget.MultiAutoCompleteTextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This demonstrates the styled text input widgets in AppCompat, such as
|
||||||
|
* {@link android.widget.EditText}, {@link android.widget.AutoCompleteTextView} and
|
||||||
|
* {@link android.widget.MultiAutoCompleteTextView}.
|
||||||
|
*/
|
||||||
|
public class AppCompatWidgetsTextInput extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.appcompat_widgets_text_input);
|
||||||
|
|
||||||
|
// Fetch the AutoCompleteTextView and set an adapter
|
||||||
|
AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(
|
||||||
|
R.id.widgets_autocompletetextview);
|
||||||
|
actv.setAdapter(new ArrayAdapter<>(this,
|
||||||
|
android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings));
|
||||||
|
|
||||||
|
// Fetch the MultiAutoCompleteTextView and set an adapter and Tokenizer
|
||||||
|
MultiAutoCompleteTextView mactv = (MultiAutoCompleteTextView) findViewById(
|
||||||
|
R.id.widgets_multiautocompletetextview);
|
||||||
|
mactv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
|
||||||
|
mactv.setAdapter(new ArrayAdapter<>(this,
|
||||||
|
android.R.layout.simple_dropdown_item_1line, Cheeses.sCheeseStrings));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user