debugging - Inherent flaw to my process of android coding -


so used creating python-ish scripts have lots of functions , these functions reference each other of time. seems natural way things me (i more of math person cs person).

however, have taken interest in android programming , want create quote generator.

essentially have no idea wrong code love pointers wrong , how can better @ android programming. working through big nerd ranch guide android programming , understand book.

this mainactivity.java

    package com.example.alex.donaldtrump; import android.app.activity; import android.media.mediaplayer; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.button; import android.widget.imagebutton; import android.widget.textview;  import java.util.random;  public class mainactivity extends activity {      button generate_button;     textview textview;     quote_generation quote_generation= new quote_generation();     string quote_gen = quote_generation.returnable();     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         string a= quote_gen;          generate_button = (button)findviewbyid(r.id.generate_button);          textview= (textview)findviewbyid(r.id.textview);          generate_button.setonclicklistener(new view.onclicklistener(){             public void generate_click(view view) {                 textview.settext(a);             }         });     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     }      }  

my quote_generation.java code here

package com.example.alex.donaldtrump; 

import java.util.random;

/** * created alex on 8/13/2015. */ public class quote_generation {

random rand= new random(); random rana = new random(); random runa = new random();  private string[] quotes= {"i\'m bit of p. t. barnum. make stars out of everyone.", "you have think anyway, why not think big?", "everything in life luck.", "all of women on apprentice flirted me - consciously or unconsciously. that\'s expected.", "the point can\'t greedy.", "show me without ego, , i\'ll show loser.", "money never big motivation me, except way keep score. real excitement playing game.", "i try learn past, plan future focusing exclusively on present. that\'s fun is.", "you know, doesn\'t matter media write long you\'ve got young , beautiful piece of ass.", "the concept of global warming created , chinese in order make u.s. manufacturing non-competitive.", "listen m-----f------, we\'re going tax 25 percent!", "when last time saw beating, let\'s say, china in trade deal? kill us. beat china time. time.", "i build great wall — , nobody builds walls better me, believe me —and i\'ll build them inexpensively. build great, great wall on our southern border, , make mexico pay wall. mark words.", "the wall go , mexico start behaving.", "our great african american president hasn\'t had positive impact on thugs happily , openly destroying baltimore!", "the kind of people want counting money little short guys wear yamakas every day.", "if running view, i'd fire rosie o\'donnell. mean, i\'d right in fat, ugly face of hers, i\'d say, rosie, you\'re fired.", "if can\'t rich dealing politicians, there\'s wrong you.", "we build school, build road, blow school, build school, build road blow them up, build again, in meantime can\'t f------ school in brooklyn.", "a certificate of live birth not same thing stretch of imagination birth certificate.", "free trade terrible. free trade can wonderful if have smart people. have stupid people.", " he\'s not war hero. he's war hero because captured. people weren\'t captured, ok, hate tell you.", "one of key problems today politics such disgrace. people don\'t go government."}; private string[] nouns = {"the chinese", "fetus concentration camps", "crack babies", "viking corporate invasion", "cecil lion", "adult business transactions", "furries", "the great wall of texas", "literally hundreds of foreigners", "cancer", "fucking leeches pre-existing conditions", "racist cunts", "warm, fluffy puppies", "sleepy-time tea", "that 1 black guy know", "eleven trades", "like, many transactions", "the flaming skull of baby jesus", "fetii", "hypothetical non-caucasian christians", "my muse", "additional pylons", "buried treasure off coast of zanzabar", "supposed war heroes", "so many foriegn rapists guys", "orphanages aren\'t returning fucking profit", "this guy know named chad", "even more damn orphans", "the smiles on little babies\' faces", "stylish comb-overs", "comb-overs every man, woman, , child", "an amendment legalizing comb-over rights", "making other hairstyles illegal" };  private int quotes_length=quotes.length; private int noun_length=nouns.length;  int randomnum = rand.nextint((quotes.length ) + 1); int ran=rana.nextint(); int run=runa.nextint();  public int getrandomnum() {     return randomnum; }  public string returnable() {      if ((randomnum % quotes_length) == 0) {         string b = "i'm bit of a" + nouns[ran % noun_length] + "i make" + nouns[run % noun_length] + "out of everyone";         return b;     } else if (randomnum % quotes_length == 1) {         string c = "you have think anyway, why not think" + nouns[run % noun_length];         return c;     } else if (randomnum % quotes_length == 2) {         string d = "everything in life is" + nouns[run % noun_length];         return d;     } else if (randomnum % quotes_length == 3) {         string e = "all of women on apprentice flirted me - consciously or unconsciously. that\'s expected.";         return e;     } else if (randomnum % quotes_length == 4) {         string f = "the point can\'t greedy.";         return f;     } else if (randomnum % quotes_length == 5) {         string g = "show me without ego, , i\'ll show loser.";         return g;     } else if (randomnum % quotes_length == 6) {         string h = "money never big motivation me, except way keep score. real excitement playing game.";         return h;     } else if (randomnum % quotes_length == 7) {         string = "i try learn past, plan future focusing exclusively on present. that\'s fun is.";         return i;     } else if (randomnum % quotes_length == 8) {         string j = "you know, doesn\'t matter media write long you\'ve got young , beautiful piece of ass.";         return j;     } else if (randomnum % quotes_length == 9) {         string k = "the concept of global warming created , chinese in order make u.s. manufacturing non-competitive.";         return k;     } else if (randomnum % quotes_length == 10) {         string l = "listen m-----f------, we\'re going tax 25 percent!";         return l;     } else if (randomnum % quotes_length == 11) {         string m = "when last time saw beating, let\'s say, china in trade deal? kill us. beat china time. time.";         return m;     } else if (randomnum % quotes_length == 12) {         string n = "i build great wall — , nobody builds walls better me, believe me —and i\'ll build them inexpensively. build great, great wall on our southern border, , make mexico pay wall. mark words.";         return n;     } else if (randomnum % quotes_length == 13) {         string o = "the wall go , mexico start behaving.";         return o;     } else if (randomnum % quotes_length == 14) {         string p = "our great african american president hasn\'t had positive impact on thugs happily , openly destroying baltimore!";         return p;     } else if (randomnum % quotes_length == 15) {         string q = "the kind of people want counting money little short guys wear yamakas every day.";         return q;     } else if (randomnum % quotes_length == 16) {         string r = "if running view, i'd fire rosie o\'donnell. mean, i\'d right in fat, ugly face of hers, i\'d say, rosie, you\'re fired.";         return r;     } else if (randomnum % quotes_length == 17) {         string s = "if can\'t rich dealing politicians, there\'s wrong you.";         return s;     } else if (randomnum % quotes_length == 18) {         string t = "we build school, build road, blow school, build school, build road blow them up, build again, in meantime can\'t f------ school in brooklyn.";         return t;     } else if (randomnum % quotes_length == 19) {         string u = "a certificate of live birth not same thing stretch of imagination birth certificate.";         return u;     } else if (randomnum % quotes_length == 20) {         string v = "free trade terrible. free trade can wonderful if have smart people. have stupid people.";         return v;     } else if (randomnum % quotes_length == 21) {         string w = " he\'s not war hero. he's war hero because captured. people weren\'t captured, ok, hate tell you.";         return w;     } else{         string x = "one of key problems today politics such disgrace. people don\'t go government.";         return x;     } } 

}

activity_mail.xml follows

    <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=".mainactivity">       <imagebutton         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:id="@+id/imagebutton"         android:layout_margintop="32dp"         android:onclick="playsound"         android:src="@drawable/angrytrump"         android:layout_alignparenttop="true"         android:layout_centerhorizontal="true" />      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textappearance="?android:attr/textappearancemedium"         android:text="@string/quote"         android:id="@+id/textview"         android:layout_above="@+id/generate_button"         android:layout_centerhorizontal="true"         android:layout_marginbottom="36dp" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="generate"         android:onclick="generate_click"         android:id="@+id/generate_button"         android:layout_above="@+id/toast_button"         android:layout_alignstart="@+id/toast_button"         android:layout_marginbottom="28dp" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="about"         android:id="@+id/toast_button"         android:layout_alignparentbottom="true"         android:layout_centerhorizontal="true" /> </relativelayout> 

this part of code:

generate_button.setonclicklistener(new view.onclicklistener(){         public void generate_click(view view) {             textview.settext(a);         }     }); 

the framework not know method generate_click - when click event occurs, expects have this:

generate_button.setonclicklistener(new view.onclicklistener(){         @override         public void onclick(view view) {             textview.settext(a);         }     }); 

the onclick method needs implemented can perform actions when click occurs.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -