Advertisement
Guest User

Quotebook

a guest
Apr 24th, 2015
2,936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.81 KB | None | 0 0
  1. package quotebook.theoneandonly.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.  
  11. import java.util.ArrayList;
  12.  
  13. //this is the important stuff from here down:
  14.  
  15. public class Quotebook extends ActionBarActivity {
  16.  
  17.     int count = 0;
  18.  
  19.  
  20.     @Override
  21.     protected void onCreate(Bundle savedInstanceState) {
  22.         super.onCreate(savedInstanceState);
  23.         setContentView(R.layout.activity_quotebook);
  24.  
  25.         RelativeLayout touch = (RelativeLayout) findViewById(R.id.touch);
  26.         final TextView quoteText = (TextView) findViewById(R.id.quote);
  27.         final TextView personText = (TextView) findViewById(R.id.person);
  28.  
  29.         final ArrayList<Quote> quoteList = new ArrayList<Quote>();
  30.  
  31.         Quote quote4 = new Quote("You're more of a fun vampire. You don't suck blood, you just suck.", "Troy Barnes");
  32.         quoteList.add(quote4);
  33.  
  34.         Quote quote1 = new Quote("Cool Beans", "Rod Kimble");
  35.         quoteList.add(quote1);
  36.  
  37.         Quote quote2 = new Quote("How can mirrors be real if our eyes aren't real", "Jaden Smith");
  38.         quoteList.add(quote2);
  39.  
  40.         Quote quote3 = new Quote("That's like me blaming owls for how bad I suck at analogies.", "Britta Perry");
  41.         quoteList.add(quote3);
  42.  
  43.         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");
  44.         quoteList.add(quote5);
  45.  
  46.  
  47.         touch.setOnClickListener(new View.OnClickListener() {
  48.             @Override
  49.             public void onClick(View view) {
  50.                 if (count >= quoteList.size()) {
  51.                     count=0;
  52.                 }
  53.                 Quote q = quoteList.get(count);
  54.                 quoteText.setText(q.getQuote());
  55.                 personText.setText(q.getPerson());
  56.                 count++;
  57.             }
  58.         });
  59.  
  60.  
  61.  
  62.     }
  63.  
  64.  
  65.     @Override
  66.     public boolean onCreateOptionsMenu(Menu menu) {
  67.         // Inflate the menu; this adds items to the action bar if it is present.
  68.         getMenuInflater().inflate(R.menu.menu_quotebook, menu);
  69.         return true;
  70.     }
  71.  
  72.     @Override
  73.     public boolean onOptionsItemSelected(MenuItem item) {
  74.         // Handle action bar item clicks here. The action bar will
  75.         // automatically handle clicks on the Home/Up button, so long
  76.         // as you specify a parent activity in AndroidManifest.xml.
  77.         int id = item.getItemId();
  78.  
  79.         //noinspection SimplifiableIfStatement
  80.         if (id == R.id.action_settings) {
  81.             return true;
  82.         }
  83.  
  84.         return super.onOptionsItemSelected(item);
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement