0

在我的 Android 应用程序中,我在主 Activity 上显示图像和文本,切换到另一个 Activity(杀死主 Activity),然后切换回主 Activity,但添加从 Flash 中提取的新图像和文本。

在启动时,我的活动按预期工作,但是当我从主要活动切换到另一个活动时,然后回到主要活动,没有显示图像或文本。

我试图使文本和图像无效(),但似乎仍然没有显示任何图像/文本。

编辑:

我可以从 Page_Activity 转到 Gallery_Activity,但是当我尝试从 Gallery_Activity 返回到 Page_Activity 时,我无法更改 XML 中定义的任何 ImageViews/TextViews。

我在下面提供了在活动之间切换的相关代码。

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<num_y_tiles; yCount++){
                int xCo = 0;
                for(int xCount=0; xCount<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<Integer> images = new ArrayList<Integer>();

                int number =  R.drawable.gallery_book1; 

                for(int i=0; i<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<Integer> 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<?> 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);


           }
        });

    }
}
4

0 回答 0