2012-03-19

Re: Practice Mid term Solutions .

'''Originally Posted By: animeshd'''

Problem 1 and Problem 2<br><br>Q1. A) Explain the difference between an Emulator and a Simulator<br>• A Simulator creates an environment via the libraries that “simulates” the mobile device’s environment. Runs Machine Code of desktop.<br>• An emulator reads machine code for the target device and creates environment on desktop that looks the phone. Runs Machine Code of the Phone.<br>Q1 B) Setting the Icon (Android)<br>• Take a 48*48 PNG- drop it in res/drawable<br>• Open AndroidManifest.xml<br>• Add attribute to application => android:icon=”@drawable/icon<br><br>Q2)<br>a) A class method<br>Open the header of your program, underneath the @interface tag, add the following line<br>+(return type) method Name: (type) param<br><br>b) Instance in Objective – C<br>-InstanceMethod{<br>//implementation<br>}<br><br>c) Argument Passing in Objective – C<br>[obj method:parameter];<br>Where obj is Class object<br>Method is a method of that class<br>Parameter is the parameter that we are passing.<br>For passing more than one parameter:<br>[obj method:parameter1 paramName2: parameter2]<br>Where paramName2 is the name of the second parameter<br><br>Group Members:<br>Dhruv Jalota<br>Animesh Dutta<br>Kevin Grant<br>Jiajie Wu<br>ChingYing Kuo

'''Originally Posted By: animeshd''' Problem 1 and Problem 2<br><br>Q1. A) Explain the difference between an Emulator and a Simulator<br>&bull; A Simulator creates an environment via the libraries that &ldquo;simulates&rdquo; the mobile device&rsquo;s environment. Runs Machine Code of desktop.<br>&bull; An emulator reads machine code for the target device and creates environment on desktop that looks the phone. Runs Machine Code of the Phone.<br>Q1 B) Setting the Icon (Android)<br>&bull; Take a 48*48 PNG- drop it in res/drawable<br>&bull; Open AndroidManifest.xml<br>&bull; Add attribute to application =&gt; android:icon=&rdquo;@drawable/icon<br><br>Q2)<br>a) A class method<br>Open the header of your program, underneath the @interface tag, add the following line<br>+(return type) method Name: (type) param<br><br>b) Instance in Objective &ndash; C<br>-InstanceMethod{<br>//implementation<br>}<br><br>c) Argument Passing in Objective &ndash; C<br>[obj method:parameter];<br>Where obj is Class object<br>Method is a method of that class<br>Parameter is the parameter that we are passing.<br>For passing more than one parameter:<br>[obj method:parameter1 paramName2: parameter2]<br>Where paramName2 is the name of the second parameter<br><br>Group Members:<br>Dhruv Jalota<br>Animesh Dutta<br>Kevin Grant<br>Jiajie Wu<br>ChingYing Kuo

-- Practice Mid term Solutions

&#039;&#039;&#039;Originally Posted By: smokkapati&#039;&#039;&#039;

Question 7:&lt;br&gt;&lt;br&gt;iPhone:&lt;br&gt;The following method will be called when the device orientation is changed. Write your code inside this method as required to change the layout.&lt;br&gt;In your ViewController.m file write this method:&lt;br&gt;&lt;br&gt;- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {&lt;br&gt; &lt;br&gt; if (interfaceOrientation == UIInterfaceOrientationPortrait) {&lt;br&gt; // This means new orientation is portrait.&lt;br&gt; } else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {&lt;br&gt; // This means new orientation is landscape left.&lt;br&gt; } else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {&lt;br&gt; // This means new orientation is landscape right.&lt;br&gt; } else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {&lt;br&gt; // This means new orientation is portrait upside down.&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;For HTML5:&lt;br&gt;(function(){<br> // Orientation Change<br> // When orientation changes event is triggered<br> // exposing an orientation property of either<br> // landscape or portrait<br> (&#039;body&#039;).bind(&#039;orientationchange&#039;, function(event){&lt;br&gt; changeOrientation(event.orientation)&lt;br&gt; })&lt;br&gt;&lt;br&gt; // Change the style depending on orientation&lt;br&gt; function changeOrientation(ori) {&lt;br&gt; // Remove all classes&lt;br&gt; (&quot;#orientation&quot;).removeClass('portrait landscape');<br> (&amp;quot;#orientation&amp;quot;).addClass(ori);&lt;br&gt; $(&amp;quot;#orientation&amp;quot;).html(&amp;quot;

&amp;quot;+ori.toUpperCase()+&amp;quot; &amp;quot;);&lt;br&gt; }&lt;br&gt;&lt;br&gt; $(&amp;quot;body&amp;quot;).trigger(&amp;quot;orientationchange&amp;quot;);&lt;br&gt; })&lt;br&gt;&lt;br&gt;Group Members:&lt;br&gt;Snigdha Mokkapati&lt;br&gt;Vy Luong&lt;br&gt;Xiu Guo

'''Originally Posted By: smokkapati''' Question 7:<br><br>iPhone:<br>The following method will be called when the device orientation is changed. Write your code inside this method as required to change the layout.<br>In your ViewController.m file write this method:<br><br>- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {<br> <br> if (interfaceOrientation == UIInterfaceOrientationPortrait) {<br> // This means new orientation is portrait.<br> } else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {<br> // This means new orientation is landscape left.<br> } else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {<br> // This means new orientation is landscape right.<br> } else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {<br> // This means new orientation is portrait upside down.<br> }<br>}<br><br>For HTML5:<br>$(function(){<br> // Orientation Change<br> // When orientation changes event is triggered<br> // exposing an orientation property of either<br> // landscape or portrait<br> $('body').bind('orientationchange', function(event){<br> changeOrientation(event.orientation)<br> })<br><br> // Change the style depending on orientation<br> function changeOrientation(ori) {<br> // Remove all classes<br> $(&quot;#orientation&quot;).removeClass('portrait landscape');<br> $(&quot;#orientation&quot;).addClass(ori);<br> $(&quot;#orientation&quot;).html(&quot; &quot;+ori.toUpperCase()+&quot; &quot;);<br> }<br><br> $(&quot;body&quot;).trigger(&quot;orientationchange&quot;);<br> })<br><br>Group Members:<br>Snigdha Mokkapati<br>Vy Luong<br>Xiu Guo

Practice Mid term Solutions

&#039;&#039;&#039;Originally Posted By: shailbenq&#039;&#039;&#039;

Solution 4 : by Chinmay bhawe, Eugene, Ajinkya amrute and Shailesh Benake&lt;br&gt;&lt;br&gt;Show the necessary code and describe any interface building activities needed to create a small app (platform of your choice from amongst those covered this semester) with a button on it, which when clicked opens an alert dialog with the words &amp;quot;Cancel Me!&amp;quot; on it. When the user clicks cancel me, the alert goes away.&lt;br&gt;&lt;br&gt;Android way -&lt;br&gt;step 1: Go to the layout (say main.xml)&lt;br&gt;step 2: Add a button to the layout,set its id to say &amp;quot;button1&amp;quot;&lt;br&gt;step 3:&lt;br&gt; Set method Attribute as,&lt;br&gt; [ android:onClick = &amp;quot;clickerMethod&amp;quot;]&lt;br&gt; now add a method by the name &amp;quot;void clickerMethod&amp;quot;&lt;br&gt;code:&lt;br&gt; Code: public void clickerMethod(View v)&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { &lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AlertDialog.Builder bd = new AlertDialog.Builder(this);&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bd.setNegativeButton(&amp;quot;Cancel Me&amp;quot;, new DialogInterface.OnClickListener(){&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void onClick(DialogInterface dialog,int d){&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dialog.cancel();&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AlertDialog confirmation = bd.create();&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;confirmation.show();&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br&gt;&lt;br&gt;&lt;br&gt;I executed the above code on emulator its working fine as mentioned in the question&lt;br&gt;

'''Originally Posted By: shailbenq''' Solution 4 : by Chinmay bhawe, Eugene, Ajinkya amrute and Shailesh Benake<br><br>Show the necessary code and describe any interface building activities needed to create a small app (platform of your choice from amongst those covered this semester) with a button on it, which when clicked opens an alert dialog with the words &quot;Cancel Me!&quot; on it. When the user clicks cancel me, the alert goes away.<br><br>Android way -<br>step 1: Go to the layout (say main.xml)<br>step 2: Add a button to the layout,set its id to say &quot;button1&quot;<br>step 3:<br> Set method Attribute as,<br> [ android:onClick = &quot;clickerMethod&quot;]<br> now add a method by the name &quot;void clickerMethod&quot;<br>code:<br> Code: public void clickerMethod(View v)<br>&nbsp; &nbsp; &nbsp; &nbsp; { <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AlertDialog.Builder bd = new AlertDialog.Builder(this);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bd.setNegativeButton(&quot;Cancel Me&quot;, new DialogInterface.OnClickListener(){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(DialogInterface dialog,int d){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dialog.cancel();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AlertDialog confirmation = bd.create();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;confirmation.show();<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br><br>I executed the above code on emulator its working fine as mentioned in the question<br>

-- Practice Mid term Solutions

&#039;&#039;&#039;Originally Posted By: arshiagrawal&#039;&#039;&#039;

Problem 6: For either iOS or Android, give the code to make the keyboard go away if the user clicks outside of the text input area.&lt;br&gt;&lt;br&gt;Android:&lt;br&gt;In the onclick method of relative layout&#039;s onClickListener, write the following code to make the keyboard go away when user clicks outside the text area - &lt;br&gt;&lt;br&gt;EditText dicEditTextID= (EditText) findViewById(R.id.EditText01);&lt;br&gt;InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);&lt;br&gt;imm.hideSoftInputFromWindow(dicEditTextID.getApplicationWindowToken(), 0);&lt;br&gt;&lt;br&gt;Group members:&lt;br&gt;Arshi&lt;br&gt;Carlos&lt;br&gt;Chinmayee

'''Originally Posted By: arshiagrawal''' Problem 6: For either iOS or Android, give the code to make the keyboard go away if the user clicks outside of the text input area.<br><br>Android:<br>In the onclick method of relative layout's onClickListener, write the following code to make the keyboard go away when user clicks outside the text area - <br><br>EditText dicEditTextID= (EditText) findViewById(R.id.EditText01);<br>InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);<br>imm.hideSoftInputFromWindow(dicEditTextID.getApplicationWindowToken(), 0);<br><br>Group members:<br>Arshi<br>Carlos<br>Chinmayee
X