Răsfoiți Sursa

Initial commit for UIFormExample project.

Cristian Tanas 11 ani în urmă
părinte
comite
ed2058b0e3

+ 27 - 0
UIFormExample/AndroidManifest.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.uab.android.ui.uiformexample"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="14"
+        android:targetSdkVersion="19" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".MainActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

BIN
UIFormExample/ic_launcher-web.png


BIN
UIFormExample/res/drawable-hdpi/ic_launcher.png


BIN
UIFormExample/res/drawable-mdpi/ic_launcher.png


BIN
UIFormExample/res/drawable-xhdpi/ic_launcher.png


BIN
UIFormExample/res/drawable-xxhdpi/ic_launcher.png


+ 177 - 0
UIFormExample/res/layout/activity_main.xml

@@ -0,0 +1,177 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="${relativePackage}.${activityClass}" >
+    
+    <TextView
+        android:id="@+id/sep1"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_marginTop="5dp"
+        android:text="@string/class_sep"
+        style="?android:attr/listSeparatorTextViewStyle" />
+
+    <TextView
+        android:id="@+id/classLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/sep1"
+        android:layout_alignParentLeft="true"
+        android:layout_marginTop="15dp"
+        android:layout_marginLeft="10dp"
+        android:text="@string/class_name" />
+
+    <AutoCompleteTextView
+        android:id="@+id/classAutoComplete"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/classLabel"
+        android:layout_alignBottom="@+id/classLabel"
+        android:layout_marginLeft="16dp"
+        android:layout_toRightOf="@+id/classLabel"
+        android:ems="10" >
+        
+        <requestFocus />
+ 	</AutoCompleteTextView>
+
+    <TextView
+        android:id="@+id/creditLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignLeft="@+id/classLabel"
+        android:layout_below="@+id/classLabel"
+        android:layout_marginTop="30dp"
+        android:text="@string/credits" />
+
+    <EditText
+        android:id="@+id/creditsEditText"
+        android:layout_width="50dp"
+        android:layout_height="wrap_content"
+        android:layout_alignBottom="@+id/creditLabel"
+        android:layout_toRightOf="@+id/creditLabel"
+        android:layout_marginLeft="16dp"
+        android:ems="10"
+        android:inputType="numberDecimal" >
+    </EditText>
+
+    <TextView
+        android:id="@+id/sep2"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/creditLabel"
+        android:layout_marginTop="25dp"
+        android:text="@string/timetable_sep"
+        style="?android:attr/listSeparatorTextViewStyle" />
+
+    <TextView
+        android:id="@+id/dayOfWeekLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignLeft="@+id/classLabel"
+        android:layout_below="@+id/sep2"
+        android:layout_marginTop="15dp"
+        android:text="@string/day_of_week" />
+
+    <CheckBox
+        android:id="@+id/checkBoxMon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/dayOfWeekLabel"
+        android:layout_marginTop="10dp"
+        android:text="@string/monday" />
+    
+    <CheckBox
+        android:id="@+id/checkBoxTue"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxMon"
+        android:layout_alignBottom="@+id/checkBoxMon"
+        android:layout_toRightOf="@+id/checkBoxMon"
+        android:text="@string/tuesday" />
+
+    <CheckBox
+        android:id="@+id/checkBoxWed"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxTue"
+        android:layout_alignBottom="@+id/checkBoxTue"
+        android:layout_toRightOf="@+id/checkBoxTue"
+        android:text="@string/wednesday" />
+
+    <CheckBox
+        android:id="@+id/checkBoxThu"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxWed"
+        android:layout_alignBottom="@+id/checkBoxWed"
+        android:layout_toRightOf="@+id/checkBoxWed"
+        android:text="@string/thursday" />
+
+    <CheckBox
+        android:id="@+id/checkBoxFri"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/checkBoxThu"
+        android:layout_alignBottom="@+id/checkBoxThu"
+        android:layout_toRightOf="@+id/checkBoxThu"
+        android:text="@string/friday" />
+
+    <TextView
+        android:id="@+id/hourLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignLeft="@+id/classLabel"
+        android:layout_below="@+id/checkBoxMon"
+        android:layout_marginTop="20dp"
+        android:text="@string/hour" />
+
+    <TextView
+        android:id="@+id/defaultHourLabel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/hourLabel"
+        android:layout_alignBottom="@+id/hourLabel"
+        android:layout_toRightOf="@+id/hourLabel"
+        android:layout_marginLeft="15dp"
+        android:text="@string/default_hour_label" />
+
+    <Button
+        android:id="@+id/setHourButton"
+        style="?android:attr/buttonStyleSmall"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignBaseline="@+id/defaultHourLabel"
+        android:layout_alignBottom="@+id/defaultHourLabel"
+        android:layout_toRightOf="@+id/defaultHourLabel"
+        android:layout_marginLeft="10dp"
+        android:text="@string/sethour" />
+
+    <Button
+        android:id="@+id/saveButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentLeft="true"
+        android:text="@string/submit" />
+
+    <Button
+        android:id="@+id/clearButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_toRightOf="@+id/saveButton"
+        android:text="@string/clear" />
+
+    <Button
+        android:id="@+id/cancelButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_toRightOf="@+id/clearButton"
+        android:text="@string/cancel" />
+
+</RelativeLayout>

+ 8 - 0
UIFormExample/res/layout/list_item.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:padding="5dp" >
+    
+
+</TextView>

+ 11 - 0
UIFormExample/res/values-v11/styles.xml

@@ -0,0 +1,11 @@
+<resources>
+
+    <!--
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+        <!-- API 11 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 12 - 0
UIFormExample/res/values-v14/styles.xml

@@ -0,0 +1,12 @@
+<resources>
+
+    <!--
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 12 - 0
UIFormExample/res/values/arrays.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    
+    <string-array name="classes">
+        <item>Desarrollo de Apps Móviles</item>
+        <item>Desarrollo de Apps en plataforma Android</item>
+        <item>Desarrollo de Apps en plataforma iOS</item>
+        <item>Desarrollo de Apps en plataforma Windows Phone</item>
+        <item>Desarrollo de Apps Multiplataforma</item>
+    </string-array>
+    
+</resources>

+ 23 - 0
UIFormExample/res/values/strings.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">UIFormExample</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="class_name">Nombre asignatura</string>
+    <string name="credits">Créditos</string>
+    <string name="class_sep">Datos asignatura</string>
+    <string name="timetable_sep">Horario</string>
+    <string name="day_of_week">Día de la semana</string>
+    <string name="monday">Lun</string>
+    <string name="tuesday">Mar</string>
+    <string name="wednesday">Mie</string>
+    <string name="thursday">Jue</string>
+    <string name="friday">Vie</string>
+    <string name="hour">Hora:</string>
+    <string name="default_hour_label">00:00</string>
+    <string name="sethour">Establecer</string>
+    <string name="submit">Guardar</string>
+    <string name="clear">Limpiar</string>
+    <string name="cancel">Cancelar</string>
+
+</resources>

+ 20 - 0
UIFormExample/res/values/styles.xml

@@ -0,0 +1,20 @@
+<resources>
+
+    <!--
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Light">
+        <!--
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        -->
+    </style>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="AppBaseTheme">
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+    </style>
+
+</resources>

+ 74 - 0
UIFormExample/src/org/uab/android/ui/uiformexample/MainActivity.java

@@ -0,0 +1,74 @@
+package org.uab.android.ui.uiformexample;
+
+import java.util.Calendar;
+
+import android.app.Activity;
+import android.app.TimePickerDialog;
+import android.app.TimePickerDialog.OnTimeSetListener;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.TimePicker;
+
+public class MainActivity extends Activity {
+	
+	AutoCompleteTextView	classesAutoCompleteTextView;
+	TextView				defaultHourTextView;
+	Button					setHourButton;
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_main);
+		
+		// Get a reference to the UI element
+		classesAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.classAutoComplete);
+		
+		// Set an ArrayAdapter containing pre-define classes names
+		ArrayAdapter<CharSequence> classesAdapter = ArrayAdapter.
+				createFromResource(this, R.array.classes, R.layout.list_item);
+		classesAutoCompleteTextView.setAdapter(classesAdapter);
+		
+		setHourButton = (Button) findViewById(R.id.setHourButton);
+		
+		// Set an OnClickListener for the set hour Button
+		setHourButton.setOnClickListener(new OnClickListener() {
+			
+			@Override
+			public void onClick(View arg0) {
+				
+				// Get an instance of a Calendar to set the current time
+				Calendar c = Calendar.getInstance();
+				int hourOfDay = c.get(Calendar.HOUR_OF_DAY);
+				int minute = c.get(Calendar.MINUTE);
+				
+				// Create a new dialog that displays a TimePicker
+				TimePickerDialog timePickerDialog = new TimePickerDialog(
+						MainActivity.this, 
+						timeSetListener, 
+						hourOfDay, 
+						minute, 
+						true);
+				timePickerDialog.show();
+			}
+		});
+		
+		defaultHourTextView = (TextView) findViewById(R.id.defaultHourLabel);
+	}
+	
+	// Implementation of the OnTimeSetListener interface
+	OnTimeSetListener timeSetListener = new OnTimeSetListener() {
+		
+		// This method is called when the user click done on the TimePicker
+		@Override
+		public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+			
+			// Set the hour and minute on the corresponding TextView
+			defaultHourTextView.setText(hourOfDay + ":" + minute);
+		}
+	};
+}