如何将参数发送到android中的java类?

时间:2015-07-10 20:01:51

标签: java

嗨,我有一个这样的课程:

public class ScrollFragment extends Fragment {

    private ObservableScrollView mScrollView;

    public static ScrollFragment newInstance() {
        return new ScrollFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       ...
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {  
        stringA1 = A1;  // A1 = "mystring"
    }
}

如何将A1传递给班级?

我使用此函数调用类:

import com.github.florent37.materialviewpager.sample.fragment.ScrollFragment;
...
ScrollFragment1.newInstance();

所以我想在调用class时将字符串发送到类:

ScrollFragment1.newInstance("mystring");

但现在我必须在课堂上改变一些东西......但是怎么样?

1 个答案:

答案 0 :(得分:0)

应通过Bundle发送数据到片段。试试这个:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox()
browser.set_window_size(650, 700)
browser.get('http://iconosquare.com/viewer.php#/tag/searchterm/grid')

mobile = browser.find_element_by_id('open-menu-mobile')
mobile.click()
search = browser.find_element_by_id('getSearch')
search.click()
search.send_keys('input search term' + Keys.RETURN)

#this gets me to the page I want to click the likes
fitness = browser.find_element_by_css_selector("a[href*='fitness/']")
fitness.click()

#here are the different codes I've tried to use to click all of the "like buttons"

#tried to create a list of all elements with "like" in the id and click on all of them.  It didn't work.
like = browser.find_elements_by_id('like')
for x in range(0,len(like)):
    if like[x].is_displayed():
        like[x].click()

#tried to create a list by class and click on everything within the list and it didn't work.
like = browser.find_elements_by_class_name('like_picto_unselected')
like.click()

AttributeError: 'list' object has no attribute 'click'