Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package quotebook.theoneandonly.com.thequotebook;
- 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.RelativeLayout;
- import android.widget.TextView;
- import java.util.ArrayList;
- //this is the important stuff from here down:
- public class Quotebook extends ActionBarActivity {
- int count = 0;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_quotebook);
- RelativeLayout touch = (RelativeLayout) findViewById(R.id.touch);
- final TextView quoteText = (TextView) findViewById(R.id.quote);
- final TextView personText = (TextView) findViewById(R.id.person);
- final ArrayList<Quote> quoteList = new ArrayList<Quote>();
- Quote quote4 = new Quote("You're more of a fun vampire. You don't suck blood, you just suck.", "Troy Barnes");
- quoteList.add(quote4);
- Quote quote1 = new Quote("Cool Beans", "Rod Kimble");
- quoteList.add(quote1);
- Quote quote2 = new Quote("How can mirrors be real if our eyes aren't real", "Jaden Smith");
- quoteList.add(quote2);
- Quote quote3 = new Quote("That's like me blaming owls for how bad I suck at analogies.", "Britta Perry");
- quoteList.add(quote3);
- 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");
- quoteList.add(quote5);
- touch.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (count >= quoteList.size()) {
- count=0;
- }
- Quote q = quoteList.get(count);
- quoteText.setText(q.getQuote());
- personText.setText(q.getPerson());
- count++;
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_quotebook, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement