我要提供刷卡设施的标签导航。对于我已经尝试本。
I want to provide tab navigation with swipe facility. For that i have tried THIS.
链接显示了用viewpager标签。类TestFragment.java是添加静态视图和类可以在此链接上找到:在这里结果但我想添加动态views.Is这可能吗?结果请建议如何实现呢?
Link which shows tabs with viewpager. The class TestFragment.java is adding static views and class can be found at this link : Here But i want to add dynamic views.Is it possible ? Please suggest how to implement it ?
感谢。
我已经做了类似的事情,我创造了基本的片段布局,然后叫从片段内的函数 FragmentActivity
,然后更新视图。
I've done something similar where I created the basic fragment layouts, then called a function inside the fragment from the FragmentActivity
which then updated the view.
要做到这一点是有一个公共的方法,例如 updateFragment(数据)
或片段相似,并调用从父 FragmentActivity 。然后片段可以访问它使用自己的布局 this.getView()
The easiest way to do it is to have a public method such as updateFragment(data)
or similar in the Fragment, and call that from the parent FragmentActivity
. The fragment can then access it's own layout using this.getView()
编辑:因此,对于你code结构的一个例子可能是:
So an example structure for your code might be:
Class FragmentActivity {
method updateFragments() {
Fragment myFrag = fragmentPagerAdapter.getItem(position);
myFrag.updateView("This is my new example string to display on the page");
}
}
Class Fragment {
public method updateView(String newData) {
((TextView) this.getView().findViewById(R.id.text1)).setText(newData);
}
}