@TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void init(Context context) {
    // Disable clipping of children so non-selected pages are visible
    setClipChildren(false);

    // Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
    // You need to set this value here if using hardware acceleration in an
    // application targeted at these releases.
    if (Build.VERSION.SDK_INT >= 11) {
      setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    // 添加ViewPager
    mPager = new ViewPager(context);
    mPager.setId(R.id.pager);
    // If hardware acceleration is enabled, you should also remove
    // clipping on the pager for its children.
    mPager.setClipChildren(false);
    mPager.setPageMargin(pageMargin);
    mPager.setOnPageChangeListener(this);
    // Necessary or the pager will only have one extra page to show
    // make this at least however many pages you can see
    mPager.setOffscreenPageLimit(calcOffscreenPageLimit());
    mPager.setLayoutParams(
        new FrameLayout.LayoutParams(pageWidth, pageHeight, Gravity.CENTER_HORIZONTAL));
    this.addView(mPager);
  }
Example #2
0
  @Override
  public void onResume() {
    super.onResume();

    //        SharedPreferences prefs = getActivity().getPreferences(Context.MODE_PRIVATE);
    //        String restoredText = prefs.getString("text", null);
    //        if (restoredText != null) {
    //            int selectionStart = prefs.getInt("selection-start", -1);
    //            int selectionEnd = prefs.getInt("selection-end", -1);
    //        }
    // this.getActivity().getSharedPreferences("com.ruu.blemco", Context.MODE_PRIVATE);

    mCurrentUser = ParseUser.getCurrentUser();
    mUsername = (TextView) getActivity().findViewById(R.id.username_in_profile_textview);
    strUser = mCurrentUser.getUsername().toString();
    mUsername.setText(strUser);

    mScore = (TextView) getActivity().findViewById(R.id.score_in_profile_textview);
    strScore = "80000";
    mScore.setText(strScore);

    mRealName = (TextView) getActivity().findViewById(R.id.real_name_in_profile_textview);
    mBio = (TextView) getActivity().findViewById(R.id.bio_in_profile_textview);

    // username/score/bio adapter
    if (mContainer == null) {
      mContainer = (PagerContainer) getView().findViewById(R.id.pager_container);
      ViewPager pager = mContainer.getViewPager();
      PagerAdapter adapter = new MyPagerAdapter();
      pager.setAdapter(adapter);

      // If hardware acceleration is enabled, you should also remove
      // clipping on the pager for its children.
      pager.setClipChildren(false);
    }

    ListView listView = (ListView) getView().findViewById(android.R.id.list);
    mProfileAdapter =
        new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, dummyValues);
    listView.setAdapter(mProfileAdapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            // int activePosts = 1;
            if (position == 0) {
              Intent intent = new Intent(getActivity(), ActivePostActivity.class);
              startActivity(intent);
            } else if (position == 1) {
              Intent intent = new Intent(getActivity(), ActivePostActivity.class);
              startActivity(intent);
            } else if (position == 2) {
              Intent intent = new Intent(getActivity(), SettingsActivity.class);
              startActivity(intent);
            }
          }
        });
  }