Imageview of another Activity

Asked

Viewed 85 times

0

How to use the imageview other’s activity?

@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {

    if (groupPosition == 0)

        switch (childPosition) {
            case 0:
                new Getimg().execute();
                Intent child0Intent = new Intent(this, ListViewLivros.class);
                postCat("http://192.168.1.207/api/v2/bookdemo/_table/cad_livro?fields=img_livro&filter=id_cat%20%3D%201", 1);

                byte[] imageAsBytes = Base64.decode(imgLiv.getBytes(), Base64.DEFAULT);
                livro2121.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length));


                startActivity(child0Intent);
                break;

            case 1:
                Intent child1Intent = new Intent(this, ListViewLivros.class);
                startActivity(child1Intent);
                break;
        }
    return false;
}

Activity I want to use the image:

public class ListViewLivros extends ListActivity  {
    String[] itemname ={
        "Safari",
        "Camera",
        "Global",
        "FireFox",
        "UC Browser",
        "Android Folder",
        "VLC Player",
        "Cold War"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    this.setListAdapter(new ArrayAdapter<String>(
            this, R.layout.mylist,
            R.id.Itemname,itemname));
    }
}

XML

  <ImageView
    android:id="@+id/livro2121"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="5dp"/>

1 answer

1


I’m not sure what you want to do. If you intend to select an image in a Activity to appear in another, you can popular a Bundle to the second Activity with the selected option. So, according to the chosen option you can load the desired image.

  • An additional: if you are going to pass the image through a Bundle, use some hash or link to load the image again instead of passing the entire image through the Bundle. The app will crash if you try to do this.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.