我要显示从互联网到主要活动的图像吗?

时间:2019-03-10 17:42:59

标签: android

//主要活动

gameListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){             @Override             public void onItemClick(AdapterView adapterView,View view,int position,long l){

            // Find the current game that was clicked on
            Games currentGame = mAdapter.getItem(position);


            // Convert the String URL into a URI object (to pass into the Intent constructor)
            Uri gameUri = Uri.parse(currentGame.getUrl());

            // Create a new intent to view the game URI
             Intent i = new Intent(GamesActivity.this,PreviewActivity.class);
             i.putExtra("value",gameUri);
             startActivity(i);


        }
    });

//第二活动

公共类PreviewActivity扩展了AppCompatActivity {

ImageView img;

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

    img = findViewById(R.id.imagePreview);

    Uri i = getIntent().getData();

    Picasso.with(this).load(i).into(img);


}

}

0 个答案:

没有答案