Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add choice plus activity

Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>
  • Loading branch information...
commit 82d5d8942c6975627ab1d42d18f3357a9960089c 1 parent 3115690
@snaewe authored
View
2  project.properties
@@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-10
+target=android-16
View
11 res/layout/activity_system_information.xml
@@ -4,6 +4,7 @@
android:layout_height="match_parent" >
<TextView
+ android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
@@ -11,4 +12,14 @@
android:text="@string/hello_world"
tools:context=".SystemInformation" />
+ <Spinner
+ android:id="@+id/choices"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_above="@+id/textView1"
+ android:layout_alignRight="@+id/textView1"
+ android:layout_marginBottom="57dp"
+ android:layout_marginRight="57dp"
+ android:entries="@array/choices_array" />
+
</RelativeLayout>
View
4 res/values/strings.xml
@@ -4,5 +4,9 @@
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_system_information">SystemInformation</string>
+ <string-array name="choices_array">
+ <item >Storage</item>
+ <item >CpuInfo</item>
+ </string-array>
</resources>
View
28 src/com/example/systemexplorer/ChoiceActivity.java
@@ -0,0 +1,28 @@
+/**
+ *
+ */
+package com.example.systemexplorer;
+
+import android.app.Activity;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+
+public class ChoiceActivity extends Activity implements OnItemSelectedListener {
+
+ /* (non-Javadoc)
+ * @see android.widget.AdapterView.OnItemSelectedListener#onItemSelected(android.widget.AdapterView, android.view.View, int, long)
+ */
+ public void onItemSelected(AdapterView<?> arg0, View view, int pos,
+ long id) {
+ // An item was selected. You can retrieve the selected item using
+ // parent.getItemAtPosition(pos)
+ }
+
+ /* (non-Javadoc)
+ * @see android.widget.AdapterView.OnItemSelectedListener#onNothingSelected(android.widget.AdapterView)
+ */
+ public void onNothingSelected(AdapterView<?> parent) {
+ }
+
+}
View
5 src/com/example/systemexplorer/SystemInformation.java
@@ -3,6 +3,8 @@
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
+import android.widget.Spinner;
+import com.example.systemexplorer.ChoiceActivity;
public class SystemInformation extends Activity {
@@ -10,6 +12,9 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_system_information);
+ Spinner spinner = (Spinner) findViewById(R.id.choices);
+ ChoiceActivity listener = new ChoiceActivity();
+ spinner.setOnItemSelectedListener(listener);
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.