Note that there are some explanatory texts on larger screens.

plurals
  1. PORandom outputing unintended images
    primarykey
    data
    text
    <p>I've seem to run into an annoyance that is probably simple to fix but I just can't figure out how to. The goal is to randomly output two different images whenever the app is opened (Images: mario.png and logo.png). It was working for a long time until I tried to change the app icon (Image: ic_launcher.png) from the default one to a new one (Image: smoke.png) in the Manifest. When I did this, the app would only output logo.png and ic_luancher.png. I tried changing the manifest back to ic_luancher.png but to no avail. Any Ideas?</p> <pre><code>public class MainActivity extends Activity { private String[] Fact; private static final Random rgenerator = new Random(); private int[] picArray = { R.drawable.logo, //This actually outputs R.drawable.mario, //This one outputs the defualt app icon although it is not the one I want. }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setBackgroundDrawable(new ColorDrawable(Color.rgb(225, 151, 51))); setContentView(R.layout.activity_main); Resources res = getResources(); Fact = res.getStringArray(R.array.Facts); String q = Fact[rgenerator.nextInt(Fact.length)]; TextView tv = (TextView) findViewById(R.id.daily); tv.setText(q); Drawable d = getResources().getDrawable(picArray[rgenerator.nextInt(picArray.length)]); ImageView ptv = (ImageView) findViewById(R.id.imageView1); ptv.setImageDrawable(d); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } </code></pre> <p>}</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/background" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/edit_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="50sp" android:layout_marginTop="20sp" android:text="@string/edit_message" android:textColor="#000000" android:textSize="30sp" &gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/daily" android:layout_width="233dp" android:layout_height="wrap_content" android:layout_marginLeft="50sp" android:layout_marginTop="30sp" android:maxLines="2" android:maxWidth="350sp" android:text="@string/daily" android:textColor="#000000" android:textSize="30sp" /&gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="50sp"/&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    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