Android 我如何从活动中的编辑文本中获取值并使用它来分割?

Android 我如何从活动中的编辑文本中获取值并使用它来分割?,android,android-fragments,android-fragmentactivity,Android,Android Fragments,Android Fragmentactivity,我想从活动中的搜索栏中获取搜索结果,并在片段中显示所有列表。我怎么做 希望这能解决您的问题。。。请在评论中告诉我……(这只是一个例子。。因为您没有提供与您的查询相关的足够信息) 我搜索了你的查询,找到了上面的链接 编辑: 步骤1:将数据从活动传递到片段 Bundle bundle = new Bundle(); bundle.putString("params", "My String data"); // set MyFragment Arguments MyFragment myObj =

我想从活动中的搜索栏中获取搜索结果,并在片段中显示所有列表。我怎么做


希望这能解决您的问题。。。请在评论中告诉我……(这只是一个例子。。因为您没有提供与您的查询相关的足够信息)

我搜索了你的查询,找到了上面的链接

编辑:

步骤1:将数据从活动传递到片段

Bundle bundle = new Bundle();
bundle.putString("params", "My String data");
// set MyFragment Arguments
MyFragment myObj = new MyFragment();
myObj.setArguments(bundle);
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString("params");
        }
    }
步骤2:将数据接收到片段

Bundle bundle = new Bundle();
bundle.putString("params", "My String data");
// set MyFragment Arguments
MyFragment myObj = new MyFragment();
myObj.setArguments(bundle);
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString("params");
        }
    }

在您的活动中声明一个接口,然后在您的片段上实现它…应该不难。可能是重复的