-2

我有一组图像 URL。单击按钮时,我想将选定的图像 URL 发送到另一个活动。

主.java

String[] imageUrl={"https://devimages.apple.com.edgekey.net/contact/images/technical-icon.png","https://devimages.apple.com.edgekey.net/contact/images/technical-icon.png", "https://devimages.apple.com.edgekey.net/contact/images/technical-icon.png"};

 Button btnNextScreen = (Button) findViewById(R.id.btnNextScreen);
        btnNextScreen.setOnClickListener(new View.OnClickListener() {


            public void onClick(View v) {

                Uri uri = Uri.parse("******");
                            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                            startActivity(intent)



            }           
        });

OpenImage.java

ImageView 图像 = (ImageView)findViewById(R.id.imageview);

接下来写什么

4

4 回答 4

0

试试这个:

Bundle bundel = new Bundle();
bundel.putStringArray("key",array);

Intent intent = new Intent(this,next.class)
intent.putExtras(bundel);
startActivity(intent);
于 2013-11-11T13:07:09.617 回答
0

要不就

intent.putExtra("strings", myStrings);

putExtra 有很多重载,原始类型的传递数组就是其中之一:)

于 2013-11-11T13:08:29.197 回答
0

使用此发送另一个活动...

        Intent intent1 = new Intent(Intent.ACTION_VIEW, uri);
        Bundle bundle = new Bundle();
        bundle.putStringArray("ArrayURL", imageUrl);
        intent1.putExtras(bundle);
        intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent1);

和获取

    Bundle b = getArguments();
    Cat_Name = b.getStringArray("ArrayURL");
于 2013-11-11T13:10:13.650 回答
0

在您的第一个活动中,

String[] data = {"Hello", "World"};
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("some_key", data);
startActivity(intent);

然后在你的 Sencon Activity 中,

// At class level
private static final String TAG = SecondActivity.class.getSimpleName();

// In onCreate
String[] data = getIntent().getExtras().getStringArray("some_key");
for (String x : data) {
    Log.i(TAG, x);  
    // Toast to display all you values one by one
    Toast.makeText(SecondActivity.this, x, Toast.LENGTH_SHORT).show();      
}

希望这可以帮助...:)

于 2013-11-11T13:16:03.097 回答