Skip to content

Commit f38e006

Browse files
committed
updated Android Actionbar
1 parent 1c25566 commit f38e006

File tree

29 files changed

+987
-21
lines changed

29 files changed

+987
-21
lines changed

ListView3d

Lines changed: 0 additions & 1 deletion
This file was deleted.

com.vogella.android.actionbar.spinner/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@
77
<string name="title_section1">Section 1</string>
88
<string name="hello_world">Hello world!</string>
99
<string name="menu_settings">Settings</string>
10+
<string-array name="dropdown">
11+
<item >Selector 1</item>
12+
<item >Selector 2</item>
13+
<item >Selector 3</item>
14+
</string-array>
1015

1116
</resources>

com.vogella.android.actionbar.spinner/src/com/vogella/android/actionbar/spinner/MainActivity.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,23 @@ protected void onCreate(Bundle savedInstanceState) {
3131
actionBar.setDisplayShowTitleEnabled(false);
3232
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
3333

34-
// Set up the dropdown list navigation in the action bar.
35-
actionBar.setListNavigationCallbacks(
34+
final String[] dropdownValues = getResources().getStringArray(
35+
R.array.dropdown);
36+
3637
// Specify a SpinnerAdapter to populate the dropdown list.
37-
new ArrayAdapter<String>(actionBar.getThemedContext(),
38-
android.R.layout.simple_list_item_1,
39-
android.R.id.text1, new String[] {
40-
getString(R.string.title_section1),
41-
getString(R.string.title_section2),
42-
getString(R.string.title_section3), }), this);
38+
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
39+
actionBar.getThemedContext(),
40+
android.R.layout.simple_spinner_item, android.R.id.text1,
41+
dropdownValues);
42+
43+
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
44+
45+
// Set up the dropdown list navigation in the action bar.
46+
actionBar.setListNavigationCallbacks(adapter, this);
47+
48+
// Use getActionBar().getThemedContext() to ensure
49+
// that the text color is always appropriate for the action bar
50+
// background rather than the activity background.
4351
}
4452

4553
@Override
@@ -60,7 +68,6 @@ public void onSaveInstanceState(Bundle outState) {
6068

6169
@Override
6270
public boolean onCreateOptionsMenu(Menu menu) {
63-
// Inflate the menu; this adds items to the action bar if it is present.
6471
getMenuInflater().inflate(R.menu.activity_main, menu);
6572
return true;
6673
}
@@ -79,24 +86,15 @@ public boolean onNavigationItemSelected(int position, long id) {
7986
}
8087

8188
/**
82-
* A dummy fragment representing a section of the app, but that simply
83-
* displays dummy text.
89+
* A dummy fragment
8490
*/
8591
public static class DummySectionFragment extends Fragment {
86-
/**
87-
* The fragment argument representing the section number for this
88-
* fragment.
89-
*/
90-
public static final String ARG_SECTION_NUMBER = "section_number";
9192

92-
public DummySectionFragment() {
93-
}
93+
public static final String ARG_SECTION_NUMBER = "placeholder_text";
9494

9595
@Override
9696
public View onCreateView(LayoutInflater inflater, ViewGroup container,
9797
Bundle savedInstanceState) {
98-
// Create a new TextView and set its text to the fragment's section
99-
// number argument value.
10098
TextView textView = new TextView(getActivity());
10199
textView.setGravity(Gravity.CENTER);
102100
textView.setText(Integer.toString(getArguments().getInt(
42.9 KB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry kind="output" path="bin/classes"/>
8+
</classpath>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.vogella.android.list.swipetodismiss</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3+
org.eclipse.jdt.core.compiler.compliance=1.6
4+
org.eclipse.jdt.core.compiler.source=1.6
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.vogella.android.listview.swipetodismiss"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk
8+
android:minSdkVersion="17"
9+
android:targetSdkVersion="17" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:icon="@drawable/ic_launcher"
14+
android:label="@string/app_name"
15+
android:theme="@style/AppTheme" >
16+
<activity
17+
android:name="com.vogella.android.listview.swipetodismiss.MainActivity"
18+
android:label="@string/app_name" >
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>
10.8 KB
Loading
Binary file not shown.

0 commit comments

Comments
 (0)