Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Fatality from Seemingly Sound Method
    primarykey
    data
    text
    <p>I am working on a simple android project but have encountered a dreaded FATAL EXCEPTION, and don't really have the know-how to determine if I am doing something off limits in the world of Android... I have this code:</p> <pre><code>private OnClickListener butonList_start = new OnClickListener(){ public void onClick(View v){ Toast.makeText(getBaseContext(), "Good Luck.", Toast.LENGTH_LONG).show(); otherBtn_1.setOnClickListener(otherListener_1); otherBtn_2.setOnClickListener(otherListener_2); aTextView.setTextSize(30); aTextView.setText(""); aTextView.setMaxLines(1); } }; </code></pre> <p>All of this executes without a hitch, until at the very end I enter this:</p> <pre><code>activate(); </code></pre> <p>Which is a reference to this code:</p> <pre><code>private void activate(){ setImage_AS(); first = selector1_AS(); second = selector2_AS(); aTextView_2.setText(first); aTextView_3.setText(second); } private void setImage_AS(){ int xxx = randm.nextInt(2); if(xxx==0){ image.setImageResource(R.drawable.crew_31242514); int op = 0; } if(xxx==1){ image.setImageResource(R.drawable.ic_launcher); int op = 1; } } private int selector1_AS(){ return randm.nextInt(50); } private int selector2_AS(){ return randm.nextInt(first); } </code></pre> <p>Through the method "activate" I set the image of a pre-defined ImageView, and give both 'first' and 'second' value through their respective methods which randomly assign values within those parameters.</p> <p>Now, nothing else happens after this unless a user presses a button, so, the error should be in here right? What am I doing wrong, I've looked over this so much but can't get any hints from the LogCat which just returns FATAL EXCEPTION and no details (unless I cannot see them).</p> <p>My code has no errors and therefore no references to objects or types that haven't been declared, and everything runs smoothly in the app until the button that activates butonList_start is clicked. Please help me!</p> <p>Here're the LogCat lines <img src="https://i.stack.imgur.com/YUb91.png" alt="enter image description here"></p> <p><strong>FOUND THE ISSUE</strong> <em>Still a tad Confused</em></p> <p>The issue was a product of my attempts to set the text of the TextView to the value given by 'first' or 'second', which was an int... But why would that be a problem, will setText() only accept Strings?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload