cc美團商家介面加上SlidePage開源項目

來源:互聯網
上載者:User

標籤:cc美團商家介面加上slidepage開源項目

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6F/CA/wKioL1WormGS3JnvAAJMUGtuBjA121.jpg" title="商家_slidePager.png" alt="wKioL1WormGS3JnvAAJMUGtuBjA121.jpg" />

1. 

package com.chencheng.meituan.fragment;


import com.astuetz.PagerSlidingTabStrip;

import com.chencheng.meituan.view.MapOverLayActivity;

import com.yuchen.meituan.R;

import com.yuchen.meituan.R.layout;


import android.content.Intent;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.support.v4.app.FragmentManager;

import android.support.v4.app.FragmentPagerAdapter;

import android.support.v4.view.ViewPager;

import android.view.LayoutInflater;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.ViewGroup;


/**

 * A simple {@link Fragment} subclass.

 *

 */

public class Shop0Fragment extends Fragment implements OnClickListener {


private final String[] TITLES = { "全部商家", "優惠商家"};

public Shop0Fragment() {

// Required empty public constructor

}


@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) {

View layout = inflater.inflate(R.layout.fragment_shop0, null);

layout.findViewById(R.id.rl_map_btn).setOnClickListener(this);

initViewPager(layout);

return layout;

}


private void initViewPager(View layout) {

ViewPager mPager = (ViewPager) layout.findViewById(R.id.pager);

PagerSlidingTabStrip tabStrip = (PagerSlidingTabStrip) layout.findViewById(R.id.tabs);

FragmentManager fm = getChildFragmentManager();

mPager.setAdapter(new BannerPagerAdapger(fm));

tabStrip.setViewPager(mPager);

}





class BannerPagerAdapger extends FragmentPagerAdapter {


public BannerPagerAdapger(FragmentManager fm) {

super(fm);

}


@Override

public CharSequence getPageTitle(int position) {

return TITLES[position];

}


public Fragment getItem(int position) {

int i =position%2;

Fragment fragment;

if(i==0){

fragment = new ShopFragment();

}else{

fragment=new ShopFragment();

}

//fragment.setTitle(TITLES[position]);

return fragment;

}

public int getCount() {

return TITLES.length;

}


}





@Override

public void onClick(View v) {

switch (v.getId()) {

case R.id.rl_map_btn:

//周邊

startActivity(new Intent(getActivity(), MapOverLayActivity.class));

break;


default:

break;

}

}



}


2.修改庫PagerSlidingTabStrip裡面indicator 和  underline的屬性



private int indicatorColor = 0xFF22B14C;

private int underlineColor = 0x1A22B14C;

private int dividerColor = 0x00E61A5F;


private boolean shouldExpand = false;

private boolean textAllCaps = true;


private int scrollOffset = 52;

private int indicatorHeight = 2;

private int underlineHeight = 4;

private int dividerPadding = 2;

private int tabPadding = 24;

private int dividerWidth = 2;


private int tabTextSize = 12;

private int tabTextColor = 0xFF22B14C;


cc美團商家介面加上SlidePage開源項目

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.