Differences

This shows you the differences between two versions of the page.

Link to this comparison view

dapm:laboratoare:04 [2018/03/16 14:30]
ioana_maria.culic
dapm:laboratoare:04 [2020/02/28 17:00] (current)
sabina.horincar
Line 27: Line 27:
 More info : https://​developer.android.com/​reference/​android/​widget/​GridLayout.html\\ More info : https://​developer.android.com/​reference/​android/​widget/​GridLayout.html\\
  
-====== Exercises ​======+====== Exercises ======
 **X & 0 GAME**\\ **X & 0 GAME**\\
 Download the next 3 image and add them in your new project in the res/​drawable folder (copy - paste) or create your own models: \\ Download the next 3 image and add them in your new project in the res/​drawable folder (copy - paste) or create your own models: \\
Line 36: Line 36:
 \\ \\
  
-**Ex 1 ** Make a new project, and using the next xml, positionate another ​image in the grid layout (in the empty spaces), following the next example: \\ +** For this lab do not use the design from xml, use only the text ! **\\ 
 +** Understand the code, at the end of the lab, the assistant will ask you questions ! ** 
 +\\ 
 +\\ 
 +**Ex 1 ** Make a new project, and using the next xml, positionate another ​image in the grid layout (in the empty spaces), following the next example: \\ 
 +**Attention !** [ImageView] The tag value and the index from the id shoud be the same !\\ 
 +Change the column, row, marginLeft and marginRight value (if necessary). 
 +\\ 
   <​RelativeLayout xmlns:​android="​http://​schemas.android.com/​apk/​res/​android"​   <​RelativeLayout xmlns:​android="​http://​schemas.android.com/​apk/​res/​android"​
     xmlns:​tools="​http://​schemas.android.com/​tools"​     xmlns:​tools="​http://​schemas.android.com/​tools"​
Line 52: Line 58:
         <​ImageView         <​ImageView
             android:​id="​@+id/​imageView0"​             android:​id="​@+id/​imageView0"​
 +            android:​tag="​0"​
             android:​layout_width="​90dp"​             android:​layout_width="​90dp"​
             android:​layout_height="​90dp"​             android:​layout_height="​90dp"​
Line 58: Line 65:
             android:​layout_column="​0"​             android:​layout_column="​0"​
             android:​layout_row="​0"​             android:​layout_row="​0"​
-            android:​onClick="​dropIn+            android:​onClick="​dropIn"/>​
-            android:​tag="​0" />+
             ​             ​
     </​GridLayout>​     </​GridLayout>​
Line 78: Line 84:
      ​ImageView counter = (ImageView) view;      ​ImageView counter = (ImageView) view;
      // get the current Image View (counter tag)      // get the current Image View (counter tag)
-     // int tagCounter ​//TODO+     ​int ​tappedCounter ​Integer.parseInt(counter.getTag().toString());​
            
      //if the space is empty(is 2) and the game is not over      //if the space is empty(is 2) and the game is not over
Line 124: Line 130:
  
  
-**Ex 3 ** In the xml file, in the relative layout, add a linear layout (layout_width="​wrap_content",​ layout_height="​wrap_content",​ visibility="​invisible",​ orientation="​vertical"​+**Ex 3 ** In the xml file, in the relative layout, add a linear layout (layout_width="​wrap_content",​ layout_height="​wrap_content",​ visibility="​invisible",​ orientation="​vertical"​, center ​it //​vertical//​ and //​horizontal//​ and add a //padding// (can be 20 dp). 
-Center ​it //​vertical//​ and //​horizontal//​ and add a //padding// (can be 20 dp).+Change its color (NOT WHITE).
 \\ \\
-In the LinearLayout add a TextView and a Button (both with width and height ​ "​wrap_content"​ and with layout_gravity= "​center_horizontal"​+In the LinearLayout add a TextView and a Button (both with width and height ​ "​wrap_content"​ and with layout_gravity= "​center_horizontal" ​). Add for the TextView and the Button a proper id.
 \\  \\ 
  
Line 141: Line 147:
       ((ImageView) gridLayout.getChildAt(i)).setImageResource(0)       ((ImageView) gridLayout.getChildAt(i)).setImageResource(0)
    }    }
 +\\
 +**Ex 6 ** Make a login page for the game like in the last lab.
 \\ \\
  
 +**BONUS** (only if you've done the exercises) \\
 +1. Change the colors and the background images as you like.
 +\\
  
 REFS:\\ REFS:\\
 http://​www.techotopia.com/​index.php/​Working_with_the_Android_GridLayout_in_XML_Layout_Resources\\ http://​www.techotopia.com/​index.php/​Working_with_the_Android_GridLayout_in_XML_Layout_Resources\\
 https://​developer.android.com/​reference/​android/​widget/​GridLayout.html\\ https://​developer.android.com/​reference/​android/​widget/​GridLayout.html\\
dapm/laboratoare/04.1521203459.txt.gz · Last modified: 2018/03/16 14:30 by ioana_maria.culic
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0