我正在处理quiz application
. 我在这里使用Viewpager indicator
。在这我已经实现了listview with radio button
。
我的问题是,如何diffent values
在viewpager
.
我尝试了谷歌,但我没有找到解决方案。请帮我。谢谢你
见下图:
检查我的代码:
class PagerAdapter extends FragmentPagerAdapter implements SwipeyTabsAdapter{
public final String[] list = new String[]
{"Operating System", "Product Of Google", "Both Above", "None of above"}
;
private final Context mContext;
public PagerAdapter(Context context, FragmentManager fm) {
super(fm);
this.mContext = context;
}
@Override
public Fragment getItem(int pos) {
return ItemFragment.newInstance(QUES[pos]);
//return ItemFragment.newInstance(QUES[pos % TITLES.length]);
}
@Override
public int getCount() {
return TITLES.length;
}
public TextView getTab(final int position, SwipeyTabs root) {
TextView view = (TextView) LayoutInflater.from(mContext).inflate(
R.layout.swipey_tab_indicator, root, false);
view.setText(TITLES[position]);
view.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mViewPager.setCurrentItem(position);
}
});
return view;
}
}
public static class ItemFragment extends Fragment{
static ItemFragment newInstance(String title) {
ItemFragment f = new ItemFragment();
// Supply num input as an argument.
Bundle args = new Bundle();
args.putString("title",title);
f.setArguments(args);
System.out.println("value of the title : ================>"+title);
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.view_question, container, false);
View tv = v.findViewById(R.id.text);
final View listvw = v.findViewById(R.id.listview);
final String title = getArguments().getString("title");
((TextView)tv).setText(title);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_single_choice, list);
((ListView) listvw).setAdapter(adapter);
((ListView) listvw).setChoiceMode(ListView.CHOICE_MODE_SINGLE);
return v;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
public void onListItemClick(ListView l, View v, int position, long id) {
Log.i("FragmentList", "Item clicked: " + id);
}
}