Advertisement
Guest User

Java issue

a guest
May 5th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.10 KB | None | 0 0
  1. activity main.xml
  2.  
  3.  
  4. <?xml version="1.0" encoding="utf-8"?>
  5. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  6.     xmlns:tools="http://schemas.android.com/tools"
  7.     android:layout_width="match_parent"
  8.     android:layout_height="match_parent"
  9.     android:background="#ffffff"
  10.     android:orientation="vertical"
  11.     android:paddingBottom="@dimen/activity_vertical_margin"
  12.     android:paddingLeft="@dimen/activity_horizontal_margin"
  13.     android:paddingRight="@dimen/activity_horizontal_margin"
  14.     android:paddingTop="@dimen/activity_vertical_margin"
  15.     android:weightSum="1"
  16.     tools:context="com.example.android.rareenglishwords.MainActivity">
  17.  
  18.     <TextView
  19.         android:id="@+id/textView"
  20.         android:layout_width="wrap_content"
  21.         android:layout_height="wrap_content"
  22.         android:layout_gravity="center_horizontal"
  23.         android:layout_weight="0.02"
  24.         android:text="Chinatown is a country." />
  25.  
  26.     <LinearLayout
  27.         android:layout_width="match_parent"
  28.         android:layout_height="wrap_content"
  29.         android:layout_weight="0.19"
  30.         android:orientation="horizontal"
  31.         android:weightSum="1">
  32.  
  33.         <Button
  34.             android:id="@+id/yesButton"
  35.             android:layout_width="wrap_content"
  36.             android:layout_height="55dp"
  37.             android:layout_gravity="center_vertical"
  38.             android:layout_weight="0.11"
  39.             android:text="Yes" />
  40.  
  41.         <Button
  42.             android:id="@+id/noButton"
  43.             android:layout_width="wrap_content"
  44.             android:layout_height="57dp"
  45.             android:layout_gravity="center_vertical"
  46.             android:layout_weight="0.23"
  47.             android:text="No" />
  48.  
  49.     </LinearLayout>
  50. </LinearLayout>
  51.    
  52.  
  53.  
  54.  
  55.  
  56. Main xml
  57.  
  58.  
  59.  
  60. package com.example.android.rareenglishwords;
  61.  
  62. import android.os.Bundle;
  63. import android.support.v7.app.AppCompatActivity;
  64. import android.view.View;
  65. import android.widget.Button;
  66. import android.widget.Toast;
  67.  
  68. public class MainActivity extends AppCompatActivity {
  69.  
  70.     public Button yesButton;
  71.     public Button noButton;
  72.  
  73.     @Override
  74.     protected void onCreate(Bundle savedInstanceState) {
  75.         super.onCreate(savedInstanceState);
  76.         setContentView(R.layout.activity_main);
  77.  
  78.         yesButton = (Button) findViewById(R.id.yesButton);
  79.         noButton = (Button) findViewById(R.id.noButton);
  80.  
  81.         yesButton.setOnClickListener(new View.OnClickListener() {
  82.             @Override
  83.             public void onClick(View v) {
  84.                 //Does nothing yet but sonn
  85.                 Toast.makeText(MainActivity.this,
  86.                         R.string.incorrect_toast,
  87.                         Toast.LENGTH_SHORT).show();
  88.             }
  89.         });
  90.  
  91.         noButton.setOnClickListener(new View.OnClickListener() {
  92.             @Override
  93.             public void onClick(View v) {
  94.                 //Does nothing yet but sonn
  95.                 Toast.makeText(MainActivity.this,
  96.                         R.string.correct_toast,
  97.                         Toast.LENGTH_SHORT).show();
  98.             }
  99.         });
  100.  
  101.  
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement