Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:id="@+id/testGridLayout"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:columnCount="1"
  7. android:orientation="horizontal" >
  8.  
  9. <android.support.v4.view.ViewPager
  10. android:id="@+id/pager"
  11. android:layout_width="match_parent"
  12. android:layout_height="match_parent"
  13. android:layout_column="0"
  14. android:layout_gravity="left|top"
  15. android:layout_row="0"
  16. tools:context=".MainActivity" >
  17.  
  18. <android.support.v4.view.PagerTitleStrip
  19. android:id="@+id/pager_title_strip"
  20. android:layout_width="match_parent"
  21. android:layout_height="wrap_content"
  22. android:layout_gravity="top"
  23. android:background="#00561B"
  24. android:paddingBottom="4dp"
  25. android:paddingTop="4dp"
  26. android:textColor="#fff" >
  27. </android.support.v4.view.PagerTitleStrip>
  28. </android.support.v4.view.ViewPager>
  29.  
  30. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  31. xmlns:tools="http://schemas.android.com/tools"
  32. android:layout_width="match_parent"
  33. android:layout_height="match_parent"
  34. android:paddingBottom="@dimen/activity_vertical_margin"
  35. android:paddingLeft="@dimen/activity_horizontal_margin"
  36. android:paddingRight="@dimen/activity_horizontal_margin"
  37. android:paddingTop="@dimen/activity_vertical_margin"
  38. android:scrollbars="vertical"
  39. tools:context=".MainActivity$DummySectionFragment" >
  40.  
  41. <TextView
  42. android:id="@+id/section_label"
  43. android:layout_width="wrap_content"
  44. android:layout_height="wrap_content"
  45. android:scrollbars="vertical" />
  46.  
  47. public class MainActivity extends FragmentActivity {
  48. SectionsPagerAdapter mSectionsPagerAdapter;
  49.  
  50. ViewPager mViewPager;
  51.  
  52. @Override
  53. protected void onCreate(Bundle savedInstanceState) {
  54. super.onCreate(savedInstanceState);
  55. setContentView(R.layout.activity_main);
  56.  
  57. // Create the adapter that will return a fragment for each of the three
  58. // primary sections of the app.
  59. mSectionsPagerAdapter = new SectionsPagerAdapter(
  60. getSupportFragmentManager());
  61.  
  62. // Set up the ViewPager with the sections adapter.
  63. mViewPager = (ViewPager) findViewById(R.id.pager);
  64. mViewPager.setAdapter(mSectionsPagerAdapter);
  65.  
  66. }
  67.  
  68. @Override
  69. public boolean onCreateOptionsMenu(Menu menu) {
  70. // Inflate the menu; this adds items to the action bar if it is present.
  71. getMenuInflater().inflate(R.menu.main, menu);
  72. return true;
  73. }
  74.  
  75. public class SectionsPagerAdapter extends FragmentPagerAdapter {
  76.  
  77. public SectionsPagerAdapter(FragmentManager fm) {
  78. super(fm);
  79. }
  80.  
  81. @Override
  82. public Fragment getItem(int position) {
  83. // getItem is called to instantiate the fragment for the given page.
  84. // Return a DummySectionFragment (defined as a static inner class
  85. // below) with the page number as its lone argument.
  86. Fragment fragment = new DummySectionFragment();
  87. Bundle args = new Bundle();
  88. args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
  89. fragment.setArguments(args);
  90. return fragment;
  91. }
  92.  
  93. @Override
  94. public int getCount() {
  95. return 2;
  96. }
  97.  
  98. @Override
  99. public CharSequence getPageTitle(int position) {
  100. Locale l = Locale.getDefault();
  101. switch (position) {
  102. case 0:
  103. return getString(R.string.title_section1).toUpperCase(l);
  104. case 1:
  105. return getString(R.string.title_section2).toUpperCase(l);
  106.  
  107. return null;
  108. }
  109. }
  110.  
  111. public static class DummySectionFragment extends Fragment {
  112. public static final String ARG_SECTION_NUMBER = "section_number";
  113.  
  114. public DummySectionFragment() {
  115.  
  116. }
  117.  
  118. @Override
  119. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  120. Bundle savedInstanceState) {
  121. View rootView = inflater.inflate(R.layout.fragment_main_dummy,container, false);
  122. TextView Letexte = (TextView) rootView.findViewById(R.id.section_label);
  123.  
  124. Letexte.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
  125. Letexte.setText("very very very long text.. n On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains");
  126. return rootView;
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement