添加自定义图像和文本

时间:2016-01-11 07:21:01

标签: android android-viewpager pagertabstrip

#[xpath3('/*:Report_Data/*:Report_Entry',payload,'NODESET')]
Adapter: here I want images

public class MyFragmentPagerAdapter extends FragmentPagerAdapter{
	
	final int PAGE_COUNT = 5;
	Context mContext;

	/** Constructor of the class */
	public MyFragmentPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	/** This method will be invoked when a page is requested to create */
	@Override
	public Fragment getItem(int arg0) {
		
		MyFragment myFragment = new MyFragment();
		Bundle data = new Bundle();
		data.putInt("current_page", arg0+1);
		myFragment.setArguments(data);
		return myFragment;
	}

	/** Returns the number of pages */
	@Override
	public int getCount() {		
		return PAGE_COUNT;
	}
	
	@Override
	public CharSequence getPageTitle(int position) {		
		
		return "Page #" + ( position + 1 );
		
	}
	

	
	
}
Fragment

public class MyFragment extends Fragment{
	
	int mCurrentPage;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		/** Getting the arguments to the Bundle object */
		Bundle data = getArguments();
		
		/** Getting integer data of the key current_page from the bundle */
		mCurrentPage = data.getInt("current_page", 0);
		
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.myfragment_layout, container,false);				
		TextView tv = (TextView ) v.findViewById(R.id.tv);
		tv.setText("You are viewing the page #" + mCurrentPage + "\n\n" + "Swipe Horizontally left / right");	
		return v;		
	}
}

我想在ViewPager中添加自定义图像和文本,就像在图像中一样(带圆圈的部分)。我正在使用此link获取文字。但我希望自定义图像高于文本,自定义字符串[]用于here等文本。 image

0 个答案:

没有答案