Advertisement
kuruza94

Untitled

Mar 5th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. //JAVA CODE
  2.  
  3. package kuruza.pizza;
  4.  
  5. import android.app.Activity;
  6. import android.support.v7.app.ActionBarActivity;
  7. import android.os.Bundle;
  8. import android.view.Menu;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.widget.Button;
  12. import android.widget.CheckBox;
  13. import android.widget.TextView;
  14. import android.widget.Toast;
  15.  
  16.  
  17. public class Pizza extends Activity implements View.OnClickListener {
  18.  
  19.  
  20. TextView Pizza;
  21. CheckBox Extra_cheese;
  22. CheckBox Chicken;
  23. Button bu;
  24.  
  25.  
  26.  
  27. @Override
  28. protected void onCreate(Bundle savedInstanceState) {
  29. super.onCreate(savedInstanceState);
  30. setContentView(R.layout.activity_pizza);
  31.  
  32. Pizza= (TextView) findViewById(R.id.pizza);
  33. Extra_cheese= (CheckBox) findViewById(R.id.cheese);
  34. Chicken= (CheckBox) findViewById(R.id.chicken);
  35. bu= (Button) findViewById(R.id.button);
  36. bu.setOnClickListener(this);
  37.  
  38. }
  39.  
  40. @Override
  41. public void onClick(View v) {
  42.  
  43. String newline=System.getProperty("line.separator");
  44. StringBuffer buffer=new StringBuffer();
  45. buffer.append(getString(R.string.Piz));
  46.  
  47. if(Extra_cheese.isChecked())
  48. {
  49. buffer.append(newline);
  50. buffer.append(R.string.Extra);
  51. }
  52. if(Chicken.isChecked())
  53. {
  54. buffer.append(newline);
  55. buffer.append(R.string.Chick);
  56. }
  57. Toast.makeText(this,buffer.toString(),Toast.LENGTH_LONG).show();
  58. }
  59. }
  60.  
  61.  
  62. //LAYOUT
  63.  
  64. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  65. xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  66. android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
  67. android:paddingRight="@dimen/activity_horizontal_margin"
  68. android:paddingTop="@dimen/activity_vertical_margin"
  69. android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".Pizza">
  70.  
  71. <TextView
  72. android:layout_width="wrap_content"
  73. android:layout_height="wrap_content"
  74. android:textAppearance="?android:attr/textAppearanceLarge"
  75. android:text="@string/Piz"
  76. android:id="@+id/pizza"
  77. android:layout_alignParentTop="true"
  78. android:layout_alignParentLeft="true"
  79. android:layout_alignParentStart="true"
  80. android:layout_marginTop="56dp" />
  81.  
  82. <CheckBox
  83. android:layout_width="wrap_content"
  84. android:layout_height="wrap_content"
  85. android:text="@string/Extra"
  86. android:id="@+id/cheese"
  87. android:layout_below="@+id/pizza"
  88. android:layout_alignParentLeft="true"
  89. android:layout_alignParentStart="true"
  90. android:layout_marginTop="40dp"
  91. android:checked="false" />
  92.  
  93. <CheckBox
  94. android:layout_width="wrap_content"
  95. android:layout_height="wrap_content"
  96. android:text="@string/Chick"
  97. android:id="@+id/chicken"
  98. android:layout_marginTop="42dp"
  99. android:checked="false"
  100. android:layout_below="@+id/cheese"
  101. android:layout_alignParentLeft="true"
  102. android:layout_alignParentStart="true" />
  103.  
  104. <Button
  105. android:layout_width="match_parent"
  106. android:layout_height="wrap_content"
  107. android:text="@string/But"
  108. android:id="@+id/button"
  109. android:layout_alignParentBottom="true"
  110. android:layout_toEndOf="@+id/chicken"
  111. android:layout_alignParentLeft="true"
  112. android:layout_alignParentStart="true" />
  113. </RelativeLayout>
  114.  
  115.  
  116. //STRINGS.XML
  117.  
  118. <resources>
  119.  
  120. <string name="app_name">Pizza</string>
  121. <string name="Piz">Pizza</string>
  122. <string name="Extra">Extra Cheese</string>
  123. <string name="Chick">Chicken</string>
  124. <string name="But">Order</string>>
  125. <string name="action_settings">Settings</string>
  126.  
  127. </resources>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement