Note that there are some explanatory texts on larger screens.

plurals
  1. POvalues arent being passed to intent
    primarykey
    data
    text
    <p>Stack Trace</p> <p><a href="http://i47.tinypic.com/33z3cxe.png" rel="nofollow">Picture of stack trace here</a></p> <p>Values arent being passed to the other intent...everytime I try to start the activity with the intent in it ...it crashes..</p> <pre><code>//This activity will retrieve and display the different rewards that are available. public class RewardsActivity extends Activity { @Override public void onCreate(Bundle SavedInstanceState) { super.onCreate(SavedInstanceState); setContentView(R.layout.rewards); //stores retrieves and stores the current gridview GridView gridView = (GridView)findViewById(R.id.grid_view); //Instance of ImageAdapter class that will load the images into the gridview gridView.setAdapter(new ImageAdapter(this)); //This function is used to set a listener on each item in the grid so that when its clicked it will go to the other view. gridView.setOnItemClickListener(new OnItemClickListener(){ public void onItemClick(AdapterView&lt;?&gt; parent, View v,int position, long id) { Intent i = new Intent(getApplicationContext(),RewardsViewActivity.class); i.putExtra("id", position); startActivity(i); } }); } </code></pre> <p>This new intent it is being passed to, when its passed here it is stored in a variable then used in a ImageView to load an image.</p> <pre><code>import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.ImageView; public class RewardsViewActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.full_view); // get intent data Intent i = getIntent(); // Selected image id int position = i.getExtras().getInt("id"); ImageAdapter imageAdapter = new ImageAdapter(this); ImageView imageView = (ImageView) findViewById(R.id.full_image); imageView.setImageResource(imageAdapter.finalImages[position]); } } </code></pre> <p>ImageAdapter.java package org.android.pps;</p> <pre><code>import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; /*This class will be used handle the loading of the image view that will display all the images of the rewards. (this will be used along with RewardsActivity and rewards.xml) */ public class ImageAdapter extends BaseAdapter { //variable that will store the current context of the application private Context c; private Integer num = 6; private int[] rewards_num=new int[num]; private Integer[] Images = new Integer[6]; public Integer[] finalImages; //for loop will set the correct image to the array if its either activated or deactivated public Integer[] fillImageArray() { //Array that will be used to show the reward images Integer[] Activated ={ R.drawable.rewards1, R.drawable.rewards2, R.drawable.rewards3, R.drawable.rewards4, R.drawable.rewards5, R.drawable.rewards6, }; Integer[] Deactivated ={ R.drawable.rewards1b, R.drawable.rewards2b, R.drawable.rewards3b, R.drawable.rewards4b, R.drawable.rewards5b, R.drawable.rewards6b, }; //for loop that checks to see all the rewards that a particular users has to assign a particular image. for(int x = 0;x&lt;rewards_num.length;x++) { for(int y = 0;y&lt;6;y++) { if(rewards_num[x]==y) { Images[x]=Activated[y]; } else { Images[x]=Deactivated[y]; } } } return Images; } //constructor with the context being passed. public ImageAdapter(Context m) { c = m; } public int getCount() { return 6; } public Object getItem(int position) { return Images[position]; } public long getItemId(int position) { return 0; } // The function View create a new ImageView for each item that is being referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { finalImages = fillImageArray(); ImageView imageView = new ImageView(c); imageView.setImageResource(finalImages[position]); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(new GridView.LayoutParams(300, 300)); return imageView; } } </code></pre>
    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