[英]how can i pass array string url in another activity?
My main activity the video list are shown in my main screen and I set the buttons in drawer, I want to display 4 button in my main screen when i click on url home which can display me url home or url_one how i can pass these links please help me out . 我的主要活动视频列表显示在主屏幕中,并且我将按钮设置在抽屉中,我想在我单击url home时在主屏幕中显示4个按钮,这样可以向我显示url home或url_one如何传递这些链接请帮帮我。
explanation: in my main screen the home_url are displayed i design four buttons in another activity home button, 1st link,2nd link and favorit button. 说明:在主屏幕上显示home_url,我在另一个活动主屏幕按钮中设计了四个按钮,即第一链接,第二链接和收藏夹按钮。 here i call the links in drawer button i want to attach the buttons in my main activity that show me home button 1st link 2nd link and favorit button when i click on home button that intent me the home_url string and display me the video list same as for other buttons. 在这里,我称抽屉按钮中的链接为我要附加的按钮,该按钮在我的主要活动中显示主页按钮1st链接2nd链接和收藏夹按钮,当我单击旨在显示home_url字符串并向我显示视频列表的主页按钮时对于其他按钮。 please help me out 请帮帮我
public class MainActivity extends AppCompatActivity implementsNavigationView.OnNavigationItemSelectedListener, AbsListView.OnScrollListener {
}
using Intent. 使用Intent。
String message = "hello there";
Intent intent = new Intent(MainActivity.this, NextActivity.class);
intent.putExtra("message", message);
startActivity(intent);
In the activity you are going to, NextActivity in this case. 在您要进行的活动中,本例中为NextActivity。
Bundle bundle = getIntent().getExtras();
String message = bundle.getString("message");
To use it 使用它
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(message);
Please note, bundle is one of the key components in Android system that is used for inter-component communications . 请注意, bundle是Android系统中用于组件间通信的关键组件之一。 All you have to think is how you can use put your Array inside that bundle. 您只需要考虑如何将Array放入该捆绑包中即可。
Sending side: 发送方:
Intent intent1 = new Intent(MainActivity.this, NextActivity.class);
Bundle bundle = new Bundle();
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("17 Fake Street");
arrayList.add("Phoney town");
arrayList.add("Makebelieveland");
/* you can add more string values in your arrayList */
bundle.putStringArrayList("myArrayListKey", arrayList);
intent1.putExtra(bundle);
startActivity(intent1);
Receiving side: 接收方:
Bundle bundle = getIntent().getExtras(); /* you got the passsed bundle */
ArrayList<String> arrayList = bundle.getStringArray("myArrayListKey");
/* you got the your passed ArrayList<String> */
/* now you can process your ArrayList<String> which you asked */
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.