wish的wish流量怎么持续分配

使用ViewPager+Fragment实现选项卡切换效果 - 简书
使用ViewPager+Fragment实现选项卡切换效果
本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动屏幕会切换Fragment并实现选项卡下方下边框条跟随移动效果。
本程序用android4.2.2真机调试,为方便部署,我使用adbWireless做为部署工具,电脑和手机接入同一局域网,在PC端输入名称adb connect 手机端ip 默认连接5555端口。之后再Eclipse的Devices中即可看到介入设备。前提是android系统需要Root。如下图:
_090912.png
创建项目(此过程不做赘述)
在activity_main.xml中设置布局。xml内容如下:&LinearLayout xmlns:android="/apk/res/android"
xmlns:tools="/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.fengzhengapp.MainActivity" &
&LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal" &
android:id="@+id/tv_hot"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#ffEAEAEA"
android:gravity="center"
android:text="@string/tab_hot"
android:textSize="18sp" /&
android:id="@+id/tv_news"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#ffEAEAEA"
android:gravity="center"
android:text="@string/tab_news"
android:textSize="18sp" /&
android:id="@+id/tv_fav"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#ffEAEAEA"
android:gravity="center"
android:text="@string/tab_favorite"
android:textSize="18sp" /&
&/LinearLayout&
&ImageView
android:id="@+id/cursor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="matrix"
android:src="@drawable/bgborder" /&
&android.support.v4.view.ViewPager
android:id="@+id/myViewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:flipInterval="30" &
&/android.support.v4.view.ViewPager&
&/LinearLayout&
上面布局页实现的效果如下:
_112628.png
接下来,增加3个Fragment布局页 ,分别在里面填充简单的内容第一个:&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &
android:id="@+id/txtHot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="this is the hot tab" &
&/TextView&
&/LinearLayout&
第二个:&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &
android:id="@+id/txtNews"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="this is the news tab" &
&/TextView&
&/LinearLayout&
第三个:&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &
android:id="@+id/txtFav"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="this is the Fav tab" &
&/TextView&
&/LinearLayout&
以上3个Fragment的布局文件已创建完毕,每个文件中只显示简单的文本内容,用做演示。
加载3个Fragment到Activity中。
首先实现3个Fragment对应的后台类
热点布局页对应的类:
import android.os.B
import android.support.v4.app.F
import android.view.LayoutI
import android.view.V
import android.view.ViewG
public class FragmentHot extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragmenthot, container, false);
news布局页对应的类:
import android.os.B
import android.support.v4.app.F
import android.view.LayoutI
import android.view.V
import android.view.ViewG
public class FragmentNews extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragmentnews, container, false);
收藏布局页对应的类:
import android.os.B
import android.support.v4.app.F
import android.view.LayoutI
import android.view.V
import android.view.ViewG
public class FragmentFavorite extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragmentfav, container, false);
之后再activity中初始化这3个Fragment
注意要点:Activity继承自FragmentActivity要实现一个FragmentPagerAdapter,内容如下:
import java.util.ArrayL
import android.support.v4.app.F
import android.support.v4.app.FragmentM
import android.support.v4.app.FragmentPagerA
public class MyFragmentAdapter extends FragmentPagerAdapter {
ArrayList&Fragment&
public MyFragmentAdapter(FragmentManager fm,ArrayList&Fragment& list){
super(fm);
this.list =
public Fragment getItem(int arg0) {
// TODO Auto-generated method stub
return list.get(arg0);
public int getCount() {
// TODO Auto-generated method stub
return list.size();
然后在Activity中实现切换和动画效果,代码如下:
import java.util.ArrayL
import android.app.A
import android.graphics.BitmapF
import android.graphics.M
import android.os.B
import android.support.v4.app.F
import android.support.v4.view.ViewP
import android.support.v4.view.ViewPager.OnPageChangeL
import android.util.DisplayM
import android.util.L
import android.view.M
import android.view.V
import android.support.v4.app.FragmentA
import android.view.MenuI
import android.view.animation.A
import android.view.animation.TranslateA
import android.widget.ImageV
import android.widget.TextV
import android.widget.T
public class MainActivity extends FragmentActivity {
private ViewPager mViewP
private ArrayL
private TextView view1, view2, view3;
private int currI
private ImageV
private static int bmpW;//横线图片宽度
priva//图片移动的偏移量
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initViewPager();
InitTextView();
InitImage();
public boolean onCreateOptionsMenu(Menu menu) {
// I this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return super.onOptionsItemSelected(item);
private void InitTextView(){
view1 = (TextView) findViewById(R.id.tv_hot);
view2 = (TextView) findViewById(R.id.tv_news);
view3 = (TextView) findViewById(R.id.tv_fav);
view1.setOnClickListener(new txtListener(0));
view2.setOnClickListener(new txtListener(1));
view3.setOnClickListener(new txtListener(2));
//内部类 重写TextView点击事件
public class txtListener implements View.OnClickListener{
private int index = 0;
public txtListener(int i){
public void onClick(View v){
mViewPager.setCurrentItem(index);
* 初始化图片的位移像素
public void InitImage(){
image = (ImageView)findViewById(R.id.cursor);
bmpW = BitmapFactory.decodeResource(getResources(), R.drawable.bgborder).getWidth();
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screenW = dm.widthP
offset = (screenW/3 - bmpW)/2;
Log.i("screenW",String.valueOf(screenW));
Log.i("bmpW",String.valueOf(bmpW));
Log.i("offset",String.valueOf(offset));
//imgageview设置平移,使下划线平移到初始位置(平移一个offset)
Matrix matrix = new Matrix();
matrix.postTranslate(offset, 0);
image.setImageMatrix(matrix);
private void initViewPager(){
mViewPager = (ViewPager)findViewById(R.id.myViewPager);
fragments = new ArrayList&Fragment&();
Fragment fragmentHot = new FragmentHot();
Fragment fragmentNews = new FragmentNews();
Fragment fragmentFav = new FragmentFavorite();
fragments.add(fragmentHot);
fragments.add(fragmentNews);
fragments.add(fragmentFav);
mViewPager.setAdapter(new MyFragmentAdapter(getSupportFragmentManager(), fragments));
mViewPager.setCurrentItem(0);
mViewPager.setOnPageChangeListener(new myOnPageChangeListener());
public class myOnPageChangeListener implements OnPageChangeListener {
private int one = offset*2 +bmpW;//两个相邻页面的偏移量
public void onPageScrolled(int arg0, float arg1, int arg2) {
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub
public void onPageSelected(int arg0) {
// TODO Auto-generated method stub
Log.i("aaaaaaaaaaaaa",String.valueOf(arg0));
Log.i("one",String.valueOf(one));
Animation animation = new TranslateAnimation(currIndex*one,arg0*one,0,0);//平移动画
currIndex = arg0;
animation.setFillAfter(true);//动画终止时停留在最后一帧,不然会回到没有执行前的状态
animation.setDuration(200);//动画持续时间0.2秒
image.startAnimation(animation);//是用ImageView来显示动画的
//int i = currIndex + 1;
// Toast.makeText(MainActivity.this, "您选择了第"+i+"个页卡", Toast.LENGTH_SHORT).show();2014年6月 .NET技术大版内专家分月排行榜第二2014年1月 .NET技术大版内专家分月排行榜第二
2014年2月 .NET技术大版内专家分月排行榜第三2013年4月 .NET技术大版内专家分月排行榜第三
2017年2月 总版技术专家分月排行榜第三
2017年5月 .NET技术大版内专家分月排行榜第一2017年4月 .NET技术大版内专家分月排行榜第一2017年3月 .NET技术大版内专家分月排行榜第一2017年2月 .NET技术大版内专家分月排行榜第一2016年10月 .NET技术大版内专家分月排行榜第一2016年8月 .NET技术大版内专家分月排行榜第一2016年7月 .NET技术大版内专家分月排行榜第一
2017年2月 总版技术专家分月排行榜第三
2017年5月 .NET技术大版内专家分月排行榜第一2017年4月 .NET技术大版内专家分月排行榜第一2017年3月 .NET技术大版内专家分月排行榜第一2017年2月 .NET技术大版内专家分月排行榜第一2016年10月 .NET技术大版内专家分月排行榜第一2016年8月 .NET技术大版内专家分月排行榜第一2016年7月 .NET技术大版内专家分月排行榜第一
2017年2月 总版技术专家分月排行榜第三
2017年5月 .NET技术大版内专家分月排行榜第一2017年4月 .NET技术大版内专家分月排行榜第一2017年3月 .NET技术大版内专家分月排行榜第一2017年2月 .NET技术大版内专家分月排行榜第一2016年10月 .NET技术大版内专家分月排行榜第一2016年8月 .NET技术大版内专家分月排行榜第一2016年7月 .NET技术大版内专家分月排行榜第一
本帖子已过去太久远了,不再提供回复功能。教程说明:
Wish后台-账户-设置几个选项的作用进行讲解:
1、速递选项(物流)。这个选项作用不大。
2、假期模式有什么作用,什么时候适合开启?
3、应用程序设置有哪些软件是支持的?货代、物流公司、第三方ERP系统、保险公司、商品分销平台等。
4、API设置(V1)和(V2)分别有什么作用?
下载提取码:
如果觉得不错,请帮帮忙分享给你的小伙伴一起学习吧!
在您的帮助下,跨境电商之家每天都在进步,感谢您的支持,谢谢!真的!
下载提取码:sn50
备份提取码:ckns
下载地址:
这些资料也许你有兴趣:有时候我们想在Ecshop后台做个设置、radio、checkbox 等等来控制页面的显示,看看Ecshop的设计,用到了shop_config这个商店设置功能
Ecshop后台增加|添加商店设置选项和使用方法详解:
第一步:在ecs_shop_config这个表增加一条设置项记录主要是parent_id、code、type、value比如:parent_id = 3
code = 'new_googds' type = 'text' value = '1月30号新品'
第二步:在后台模板增加这些选项的表单
第三步:增加语言项,在languages/zh_cn/admin/shop_config.php增加
第四步:在前台php里面调用$_CFG['...'],后台核心php里调用$GLOBALS['_CFG']['...'],然后模板调用$cfg.new_googds &(例如:前台php页面:$_CFG['new_goods'] & 后端核心php文件:$GLOBALS['_CFG']['new_goods']&& & 模板页面: $cfg.new_goods)
就这四步就可以了
阅读(...) 评论()

我要回帖

更多关于 wish怎么查看流量 的文章

 

随机推荐