Android多个页面滑动视图实现(3)

package com.xxx;


import com.ex84.ScrollLayout.OnScreenChangedListener;


import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.ImageView;
import android.widget.TextView;


public class MainActivity extends Activity implements OnScreenChangedListener {
private ImageView mImageView;
private TextView mTextView;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ScrollLayout scrollLayout = (ScrollLayout) findViewById(R.id.ScrollLayoutID);
int curScreen = scrollLayout.getCurScreen();


scrollLayout.setOnScreenChangedListener(this);
mImageView = (ImageView) findViewById(R.id.imageView1);

mTextView = (TextView) findViewById(R.id.textView_header);
}


@Override
public void onScreenChanged(ScrollLayout sc, int whichScreen) {

switch (whichScreen) {
case 0:
mImageView.setImageResource(R.drawable.btn_star_0);
mTextView.setText("left page");
break;
case 1:
mTextView.setText("center page");
mImageView.setImageResource(R.drawable.btn_star_1);
break;
case 2:
mTextView.setText("right page");
mImageView.setImageResource(R.drawable.btn_star_2);
break;
}
}


}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wysfws.html