Advertisement
Crenox

The Quotebook Android Studio Program

Apr 27th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.84 KB | None | 0 0
  1. package samkough.com.thequotebook;
  2.  
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.os.Bundle;
  5. import android.view.Menu;
  6. import android.view.MenuItem;
  7. import android.view.View;
  8. import android.widget.RelativeLayout;
  9. import android.widget.TextView;
  10. import java.util.ArrayList;
  11.  
  12. public class Quotebook extends ActionBarActivity
  13. {
  14. int count = 0;
  15.  
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState)
  18. {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.activity_quotebook);
  21.  
  22. RelativeLayout touch = (RelativeLayout) findViewById(R.id.touch);
  23. final TextView quoteText = (TextView) findViewById(R.id.quote);
  24. final TextView personText = (TextView) findViewById(R.id.person);
  25. final ArrayList<Quote> quoteList = new ArrayList<Quote>();
  26.  
  27. Quote quote4 = new Quote("You're more of a fun vampire. You don't suck blood, you just suck.", "Troy Barnes");
  28. quoteList.add(quote4);
  29.  
  30. Quote quote1 = new Quote("Cool Beans", "Rod Kimble");
  31. quoteList.add(quote1);
  32.  
  33. Quote quote2 = new Quote("How can mirrors be real if our eyes aren't real", "Jaden Smith");
  34. quoteList.add(quote2);
  35.  
  36. Quote quote3 = new Quote("That's like me blaming owls for how bad I suck at analogies.", "Britta Perry");
  37. quoteList.add(quote3);
  38.  
  39. Quote quote5 = new Quote("I was gonna be the first person in my family to graduate from community college. Everyone else graduated from normal college", "Troy Barnes");
  40. quoteList.add(quote5);
  41.  
  42. touch.setOnClickListener(new View.OnClickListener()
  43. {
  44. @Override
  45. public void onClick(View view)
  46. {
  47. if (count < quoteList.size())
  48. {
  49. Quote q = quoteList.get(count);
  50. quoteText.setText(q.getQuote());
  51. personText.setText(q.getPerson());
  52. count = count + 1;
  53. }
  54. else
  55. {
  56. count = 0;
  57. }
  58. }
  59. });
  60. }
  61.  
  62. /*public Quote quotes()
  63. {
  64. final ArrayList<Quote> quoteList = new ArrayList<Quote>();
  65. Quote quote4 = new Quote("You're more of a fun vampire. You don't suck blood, you just suck.", "Troy Barnes");
  66. quoteList.add(quote4);
  67.  
  68. Quote quote1 = new Quote("Cool Beans", "Rod Kimble");
  69. quoteList.add(quote1);
  70.  
  71. Quote quote2 = new Quote("How can mirrors be real if our eyes aren't real", "Jaden Smith");
  72. quoteList.add(quote2);
  73.  
  74. Quote quote3 = new Quote("That's like me blaming owls for how bad I suck at analogies.", "Britta Perry");
  75. quoteList.add(quote3);
  76.  
  77. Quote quote5 = new Quote("I was gonna be the first person in my family to graduate from community college. Everyone else graduated from normal college", "Troy Barnes");
  78. quoteList.add(quote5);
  79. }*/
  80.  
  81. @Override
  82. public boolean onCreateOptionsMenu(Menu menu)
  83. {
  84. // Inflate the menu; this adds items to the action bar if it is present.
  85. getMenuInflater().inflate(R.menu.menu_quotebook, menu);
  86. return true;
  87. }
  88.  
  89. @Override
  90. public boolean onOptionsItemSelected(MenuItem item)
  91. {
  92. // Handle action bar item clicks here. The action bar will
  93. // automatically handle clicks on the Home/Up button, so long
  94. // as you specify a parent activity in AndroidManifest.xml.
  95. int id = item.getItemId();
  96.  
  97. //noinspection SimplifiableIfStatement
  98. if (id == R.id.action_settings)
  99. {
  100. return true;
  101. }
  102.  
  103. return super.onOptionsItemSelected(item);
  104. }
  105. }
  106.  
  107. -------------------------------------------------------------------------------------------------------------------------------
  108. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  109. xmlns:tools="http://schemas.android.com/tools"
  110. android:layout_width="match_parent"
  111. android:layout_height="match_parent"
  112. android:paddingLeft="@dimen/activity_horizontal_margin"
  113. android:paddingRight="@dimen/activity_horizontal_margin"
  114. android:paddingTop="@dimen/activity_vertical_margin"
  115. android:paddingBottom="@dimen/activity_vertical_margin"
  116. android:id="@+id/touch">
  117. <TextView
  118. android:text="Tap the screen to inkfa"
  119. android:id="@+id/quote"
  120. android:layout_width="match_parent"
  121. android:layout_height="wrap_content"
  122. android:fontFamily="sans-serif-medium"
  123. android:textSize="26sp"
  124. android:layout_gravity="center"
  125. android:layout_above="@+id/person"
  126. android:textColor="#ffff0000"
  127. android:layout_alignParentLeft="true"
  128. android:layout_alignParentStart="true" />
  129. <TextView
  130. android:text=""
  131. android:layout_width="match_parent"
  132. android:layout_height="wrap_content"
  133. android:fontFamily="sans-serif-medium"
  134. android:textSize="26sp"
  135. android:gravity="end"
  136. android:textColor="#ffff0000"
  137. android:layout_gravity="center"
  138. android:id="@+id/person"
  139. android:layout_alignParentBottom="true"
  140. android:layout_alignLeft="@+id/quote"
  141. android:layout_alignStart="@+id/quote" />
  142. </RelativeLayout>
  143. -------------------------------------------------------------------------------------------------------------------------------
  144. package samkough.com.thequotebook;
  145.  
  146. /**
  147. * Created by Sammy on 4/27/2015.
  148. */
  149. public class Quote
  150. {
  151. public String quote;
  152. public String person;
  153.  
  154. public Quote(String mQuote, String mPerson)
  155. {
  156. quote = mQuote;
  157. person = mPerson;
  158. }
  159.  
  160. public String getPerson()
  161. {
  162. return person;
  163. }
  164.  
  165. public String getQuote()
  166. {
  167. return quote;
  168. }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement