Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Updating TextView/ImageView
    primarykey
    data
    text
    <p>In my Android application I am displaying an image &amp; text on the main activity, switching to another activity (killing the main activity), and then switching back to the main activity but adding a new image and text pulled from flash.</p> <p>On start-up my activity works as intended, but when I switch from my main activity to another activity, then come back to the main one no image or text is shown. </p> <p>I tried to invalidate() the text and image but seems to still not be showing any image/text.</p> <p><strong>Edit:</strong></p> <p>I can go from Page_Activity to Gallery_Activity, but when I try to go back to Page_Activity from Gallery_Activity I can't change any of the ImageViews/TextViews that are defined in the XML.</p> <p>I provided the relevant code for switching between activities below. </p> <pre><code>private void display_page(int pg_num) { image_overlay = Bitmap.createBitmap(canvas_width, canvas_height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(image_overlay); int yCo = 0; for(int yCount=0; yCount&lt;num_y_tiles; yCount++){ int xCo = 0; for(int xCount=0; xCount&lt;num_x_tiles; xCount++){ //code to get bufferedimage from flash (works) old_tiles[xCount][yCount] = bufferedimage; canvas.drawBitmap(old_tiles[xCount][yCount], xCo, yCo, null); xCo += TILE_WIDTH; } yCo+= TILE_HEIGHT; } imageview_overlay.setImageBitmap(image_overlay); imageview_overlay.setVisibility(View.VISIBLE); imageview_overlay.invalidate(); textview_page_number.setText("Page " + page_number); textview_page_number.invalidate(); } /* *Inside the click listener to go to Gallery_Activity */ Intent intent = new Intent(v.getContext(), Gallery_Activity.class); boolean is_books_empty = true; String[] stringArray; ArrayList&lt;Integer&gt; images = new ArrayList&lt;Integer&gt;(); int number = R.drawable.gallery_book1; for(int i=0; i&lt;stringArray.length; i++){ images.add(i, R.drawable.gallery_book1); } intent.putExtra("StringArray", ); intent.putIntegerArrayListExtra("BookImages", images); startActivity(intent); finish(); public class Gallery_Activity extends Activity{ public String[] names; public ArrayList&lt;Integer&gt; images; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery); images = getIntent().getIntegerArrayListExtra("BookImages"); names = getIntent().getStringArrayExtra("StringArray"); GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter (new ImageAdapter(this, names, images)); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { Intent intent = new Intent(v.getContext(), Page_Activity.class); String book_names = names[position]; intent.putExtra("BookName", book_names); startActivity(intent); } }); } } </code></pre>
    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.
    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