Permalink
Browse files

add choice plus activity

Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>
  • Loading branch information...
1 parent 3115690 commit 82d5d8942c6975627ab1d42d18f3357a9960089c @snaewe committed Oct 15, 2012
View
@@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-10
+target=android-16
@@ -4,11 +4,22 @@
android:layout_height="match_parent" >
<TextView
+ android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
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,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>
@@ -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) {
+ }
+
+}
@@ -3,13 +3,18 @@
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 {
@Override
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

0 comments on commit 82d5d89

Please sign in to comment.