Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //JAVA CODE
- package kuruza.pizza;
- import android.app.Activity;
- import android.support.v7.app.ActionBarActivity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.CheckBox;
- import android.widget.TextView;
- import android.widget.Toast;
- public class Pizza extends Activity implements View.OnClickListener {
- TextView Pizza;
- CheckBox Extra_cheese;
- CheckBox Chicken;
- Button bu;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_pizza);
- Pizza= (TextView) findViewById(R.id.pizza);
- Extra_cheese= (CheckBox) findViewById(R.id.cheese);
- Chicken= (CheckBox) findViewById(R.id.chicken);
- bu= (Button) findViewById(R.id.button);
- bu.setOnClickListener(this);
- }
- @Override
- public void onClick(View v) {
- String newline=System.getProperty("line.separator");
- StringBuffer buffer=new StringBuffer();
- buffer.append(getString(R.string.Piz));
- if(Extra_cheese.isChecked())
- {
- buffer.append(newline);
- buffer.append(R.string.Extra);
- }
- if(Chicken.isChecked())
- {
- buffer.append(newline);
- buffer.append(R.string.Chick);
- }
- Toast.makeText(this,buffer.toString(),Toast.LENGTH_LONG).show();
- }
- }
- //LAYOUT
- <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" android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".Pizza">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:text="@string/Piz"
- android:id="@+id/pizza"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_marginTop="56dp" />
- <CheckBox
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/Extra"
- android:id="@+id/cheese"
- android:layout_below="@+id/pizza"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_marginTop="40dp"
- android:checked="false" />
- <CheckBox
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/Chick"
- android:id="@+id/chicken"
- android:layout_marginTop="42dp"
- android:checked="false"
- android:layout_below="@+id/cheese"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true" />
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/But"
- android:id="@+id/button"
- android:layout_alignParentBottom="true"
- android:layout_toEndOf="@+id/chicken"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true" />
- </RelativeLayout>
- //STRINGS.XML
- <resources>
- <string name="app_name">Pizza</string>
- <string name="Piz">Pizza</string>
- <string name="Extra">Extra Cheese</string>
- <string name="Chick">Chicken</string>
- <string name="But">Order</string>>
- <string name="action_settings">Settings</string>
- </resources>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement