一个简单的学生管理系统

  • 效果演示
    • 实现功能总览
      • 代码

效果演示

随手做的一个小玩意,还有很多功能没有完善,倘有疏漏,万望海涵。

实现功能总览

实现了登录、注册、忘记密码、成绩查询、考勤情况、课表查看、提交作业、课程打卡等。

代码

登录与忘记密码界面
登录与忘记密码界面采用的是TabLayout+ViewPager+PagerAdapter实现的
一、添加布局文件

 View View_HomePager = LayoutInflater.from( Student.this ).inflate( R.layout.homeppage_item,null,false );View View_Data = LayoutInflater.from( Student.this ).inflate( R.layout.data_item,null,false );View View_Course = LayoutInflater.from( Student.this ).inflate( R.layout.course_item,null,false );View View_My = LayoutInflater.from( Student.this ).inflate( R.layout.my_item,null,false );
private List<View> Views = new ArrayList<>(  );
 Views.add( View_HomePager );Views.add( View_Data );Views.add( View_Course );Views.add( View_My );

二、添加标题文字

private List<String> Titles = new ArrayList<>(  );
Titles.add( "首页" );
Titles.add( "数据" );
Titles.add( "课程" );
Titles.add( "我的" );

三、绑定适配器

/*PagerAdapter 适配器代码如下*/
public class ViewPagerAdapter extends PagerAdapter {private List<View> Views;private List<String> Titles;public ViewPagerAdapter(List<View> Views,List<String> Titles){this.Views = Views;this.Titles = Titles;}@Overridepublic int getCount() {return Views.size();}@Overridepublic boolean isViewFromObject(@NonNull View view, @NonNull Object object) {return view == object;}@NonNull@Overridepublic Object instantiateItem(@NonNull ViewGroup container, int position) {container.addView( Views.get( position ) );return Views.get( position );}@Overridepublic void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {container.removeView( Views.get( position ) );}@Nullable@Overridepublic CharSequence getPageTitle(int position) {return Titles.get( position );}
}
 ViewPagerAdapter adapter = new ViewPagerAdapter( Views,Titles );for (String title : Titles){Title.addTab( Title.newTab().setText( title ) );}Title.setupWithViewPager( viewPager );viewPager.setAdapter( adapter );

注册界面
一、创建两个Drawable文件
其一

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="#63B8FF"/><size android:width="20dp" android:height="20dp"/>
</shape>

其二

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"><solid android:color="#ffffff"/><size android:height="20dp" android:width="20dp"/><stroke android:width="1dp" android:color="#EAEAEA"/>
</shape>

二、将其添加数组内

private final int[] Identity = {R.drawable.press_oval_textview,R.drawable.notpress_oval_textview};

三、动态变化背景

 private void SelectStudent(){mIdentity_Student.setBackgroundResource( Identity[0] );mIdentity_Teacher.setBackgroundResource( Identity[1] );}private void SelectTeacher(){mIdentity_Student.setBackgroundResource( Identity[1] );mIdentity_Teacher.setBackgroundResource( Identity[0] );}

考勤界面
主要是通过绘制一个圆,圆环、内圆、文字分别使用不同的背景颜色,并将修改背景颜色的接口暴露出来。
一、CircleProgressBar代码如下

public class CircleProgressBar extends View {// 画实心圆的画笔private Paint mCirclePaint;// 画圆环的画笔private Paint mRingPaint;// 画圆环的画笔背景色private Paint mRingPaintBg;// 画字体的画笔private Paint mTextPaint;// 圆形颜色private int mCircleColor;// 圆环颜色private int mRingColor;// 圆环背景颜色private int mRingBgColor;// 半径private float mRadius;// 圆环半径private float mRingRadius;// 圆环宽度private float mStrokeWidth;// 圆心x坐标private int mXCenter;// 圆心y坐标private int mYCenter;// 字的长度private float mTxtWidth;// 字的高度private float mTxtHeight;// 总进度private int mTotalProgress = 100;// 当前进度private double mProgress;public CircleProgressBar(Context context) {super( context );}public CircleProgressBar(Context context, @Nullable AttributeSet attrs) {super( context, attrs );initAttrs(context,attrs);initVariable();}public CircleProgressBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {super( context, attrs, defStyleAttr );}private void initAttrs(Context context, AttributeSet attrs) {TypedArray typeArray = context.getTheme().obtainStyledAttributes(attrs,R.styleable.TasksCompletedView, 0, 0);mRadius = typeArray.getDimension(R.styleable.TasksCompletedView_radius, 80);mStrokeWidth = typeArray.getDimension(R.styleable.TasksCompletedView_strokeWidth, 10);mCircleColor = typeArray.getColor(R.styleable.TasksCompletedView_circleColor, 0xFFFFFFFF);mRingColor = typeArray.getColor(R.styleable.TasksCompletedView_ringColor, 0xFFFFFFFF);mRingBgColor = typeArray.getColor(R.styleable.TasksCompletedView_ringBgColor, 0xFFFFFFFF);mRingRadius = mRadius + mStrokeWidth / 2;}private void initVariable() {//内圆mCirclePaint = new Paint();mCirclePaint.setAntiAlias(true);mCirclePaint.setColor(mCircleColor);mCirclePaint.setStyle(Paint.Style.FILL);//外圆弧背景mRingPaintBg = new Paint();mRingPaintBg.setAntiAlias(true);mRingPaintBg.setColor(mRingBgColor);mRingPaintBg.setStyle(Paint.Style.STROKE);mRingPaintBg.setStrokeWidth(mStrokeWidth);//外圆弧mRingPaint = new Paint();mRingPaint.setAntiAlias(true);mRingPaint.setColor(mRingColor);mRingPaint.setStyle(Paint.Style.STROKE);mRingPaint.setStrokeWidth(mStrokeWidth);//mRingPaint.setStrokeCap(Paint.Cap.ROUND);//设置线冒样式,有圆 有方//中间字mTextPaint = new Paint();mTextPaint.setAntiAlias(true);mTextPaint.setStyle(Paint.Style.FILL);mTextPaint.setColor(mRingColor);mTextPaint.setTextSize(mRadius / 2);Paint.FontMetrics fm = mTextPaint.getFontMetrics();mTxtHeight = (int) Math.ceil(fm.descent - fm.ascent);}@Overrideprotected void onDraw(Canvas canvas) {super.onDraw( canvas );mXCenter = getWidth() / 2;mYCenter = getHeight() / 2;//内圆canvas.drawCircle( mXCenter, mYCenter, mRadius, mCirclePaint );//外圆弧背景RectF oval1 = new RectF();oval1.left = (mXCenter - mRingRadius);oval1.top = (mYCenter - mRingRadius);oval1.right = mRingRadius * 2 + (mXCenter - mRingRadius);oval1.bottom = mRingRadius * 2 + (mYCenter - mRingRadius);canvas.drawArc( oval1, 0, 360, false, mRingPaintBg ); //圆弧所在的椭圆对象、圆弧的起始角度、圆弧的角度、是否显示半径连线//外圆弧if (mProgress > 0) {RectF oval = new RectF();oval.left = (mXCenter - mRingRadius);oval.top = (mYCenter - mRingRadius);oval.right = mRingRadius * 2 + (mXCenter - mRingRadius);oval.bottom = mRingRadius * 2 + (mYCenter - mRingRadius);canvas.drawArc( oval, -90, ((float) mProgress / mTotalProgress) * 360, false, mRingPaint ); ////字体String txt = mProgress + "%";mTxtWidth = mTextPaint.measureText( txt, 0, txt.length() );canvas.drawText( txt, mXCenter - mTxtWidth / 2, mYCenter + mTxtHeight / 4, mTextPaint );}}//设置进度public void setProgress(double progress) {mProgress = progress;postInvalidate();//重绘}public void setCircleColor(int Color){mRingPaint.setColor( Color );postInvalidate();//重绘}
}

签到界面
签到界面就倒计时和位置签到
一、倒计时
采用的是Thread+Handler
在子线程内总共发生两种标志至Handler内,0x00表示倒计时未完成,0x01表示倒计时完成。

private void CountDown(){new Thread(  ){@Overridepublic void run() {super.run();for (int j = 14; j >= 0 ; j--) {for (int i = 59; i >= 0; i--) {Message message = handler.obtainMessage();message.what = 0x00;message.arg1 = i;message.arg2 = j;handler.sendMessage( message );try {Thread.sleep( 1000 );} catch (InterruptedException e) {e.printStackTrace();}}}Message message = handler.obtainMessage(  );message.what = 0x01;handler.sendMessage( message );}}.start();}
 final Handler handler = new Handler(  ){@Overridepublic void handleMessage(@NonNull Message msg) {super.handleMessage( msg );switch (msg.what){case 0x00:if (msg.arg2 >= 10){SignInMinutes.setText( msg.arg2+":" );}else if (msg.arg2 < 10 && msg.arg2 > 0){SignInMinutes.setText( "0"+msg.arg2+":" );}else {SignInMinutes.setText( "00"+":" );}if (msg.arg1 >= 10){SignInSeconds.setText( msg.arg1+"" );}else if (msg.arg1 < 10 && msg.arg1 > 0){SignInSeconds.setText( "0"+msg.arg1 );}else {SignInSeconds.setText( "00" );}break;case 0x01:SignInSeconds.setText( "00" );SignInMinutes.setText( "00:" );break;}}};

一、位置签到
位置签到采用的是百度地图SDK


public class LocationCheckIn extends AppCompatActivity {private MapView BaiDuMapView;private TextView CurrentPosition,mLatitude,mLongitude,CurrentDate,SignInPosition;private Button SubmitMessage,SuccessSignIn;private ImageView LocationSignIn_Exit;private  View view = null;private PopupWindow mPopupWindow;private LocationClient client;private BaiduMap mBaiduMap;private double Latitude = 0;private double Longitude = 0;private boolean isFirstLocate = true;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate( savedInstanceState );if (Build.VERSION.SDK_INT >= 21) {View decorView = getWindow().getDecorView();decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE );getWindow().setStatusBarColor( Color.TRANSPARENT );}SDKInitializer.initialize( getApplicationContext() );client = new LocationClient( getApplicationContext() );//获取全局Contextclient.registerLocationListener( new MyBaiDuMap() );//注册一个定位监听器,获取位置信息,回调此定位监听器setContentView( R.layout.activity_location_check_in );InitView();InitBaiDuMap();InitPermission();InitPopWindows();Listener();}private void InitView(){BaiDuMapView = findViewById( R.id.BaiDu_MapView );CurrentPosition = findViewById( R.id.CurrentPosition );SubmitMessage = findViewById( R.id.SubmitMessage );mLatitude = findViewById( R.id.Latitude );mLongitude = findViewById( R.id.Longitude );LocationSignIn_Exit = findViewById( R.id.LocationSignIn_Exit );}private void InitPopWindows(){view = LayoutInflater.from( LocationCheckIn.this ).inflate( R.layout.signin_success ,null,false);CurrentDate = view.findViewById( R.id.CurrentDate );SignInPosition = view.findViewById( R.id.SignInPosition );SuccessSignIn = view.findViewById( R.id.Success);mPopupWindow = new PopupWindow( view, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT );mPopupWindow.setFocusable( true ); //获取焦点mPopupWindow.setBackgroundDrawable( new BitmapDrawable() );mPopupWindow.setOutsideTouchable( true ); //点击外面地方,取消mPopupWindow.setTouchable( true ); //允许点击mPopupWindow.setAnimationStyle( R.style.MyPopupWindow ); //设置动画Calendar calendar = Calendar.getInstance();int Hour = calendar.get( Calendar.HOUR_OF_DAY );int Minute = calendar.get( Calendar.MINUTE );String sHour,sMinute;if (Hour < 10){sHour = "0"+Hour;}else {sHour = ""+Hour;}if (Minute < 10){sMinute = "0"+Minute;}else {sMinute = ""+Minute;}CurrentDate.setText( sHour+":"+sMinute );//SignInPosition.setText( Position+"000");SuccessSignIn.setOnClickListener( new View.OnClickListener() {@Overridepublic void onClick(View v) {mPopupWindow.dismiss();}} );}private void ShowPopWindows(){mPopupWindow.showAtLocation( view, Gravity.CENTER,0,0 );}private void InitBaiDuMap(){/*百度地图初始化*/mBaiduMap = BaiDuMapView.getMap();//获取实例,可以对地图进行一系列操作,比如:缩放范围,移动地图mBaiduMap.setMyLocationEnabled(true);//允许当前设备显示在地图上}private void navigateTo(BDLocation location){if (isFirstLocate){LatLng lng = new LatLng(location.getLatitude(),location.getLongitude());//指定经纬度MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(lng);mBaiduMap.animateMapStatus(update);update = MapStatusUpdateFactory.zoomTo(16f);//百度地图缩放级别限定在3-19mBaiduMap.animateMapStatus(update);isFirstLocate = false;}MyLocationData.Builder builder = new MyLocationData.Builder();builder.latitude(location.getLatitude());//纬度builder.longitude(location.getLongitude());//经度MyLocationData locationData = builder.build();mBaiduMap.setMyLocationData(locationData);}private void InitPermission(){List<String> PermissionList = new ArrayList<>();//判断权限是否授权if (ContextCompat.checkSelfPermission( LocationCheckIn.this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED) {PermissionList.add( Manifest.permission.ACCESS_FINE_LOCATION );}if (ContextCompat.checkSelfPermission( LocationCheckIn.this, Manifest.permission.READ_PHONE_STATE ) != PackageManager.PERMISSION_GRANTED) {PermissionList.add( Manifest.permission.READ_PHONE_STATE );}if (ContextCompat.checkSelfPermission( LocationCheckIn.this, Manifest.permission.WRITE_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED) {PermissionList.add( Manifest.permission.WRITE_EXTERNAL_STORAGE );}if (!PermissionList.isEmpty()) {String[] Permissions = PermissionList.toArray( new String[PermissionList.size()] );//转化为数组ActivityCompat.requestPermissions( LocationCheckIn.this, Permissions, 1 );//一次性申请权限} else {/*****************如果权限都已经声明,开始配置参数*****************/requestLocation();}}//执行private void requestLocation(){initLocation();client.start();}/*******************初始化百度地图各种参数*******************/public  void initLocation() {LocationClientOption option = new LocationClientOption();option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);/**可选,设置定位模式,默认高精度LocationMode.Hight_Accuracy:高精度;* LocationMode. Battery_Saving:低功耗;LocationMode. Device_Sensors:仅使用设备;*/option.setCoorType("bd09ll");/**可选,设置返回经纬度坐标类型,默认gcj02gcj02:国测局坐标;bd09ll:百度经纬度坐标;bd09:百度墨卡托坐标;海外地区定位,无需设置坐标类型,统一返回wgs84类型坐标*/option.setScanSpan(3000);/**可选,设置发起定位请求的间隔,int类型,单位ms如果设置为0,则代表单次定位,即仅定位一次,默认为0如果设置非0,需设置1000ms以上才有效*/option.setOpenGps(true);/**可选,设置是否使用gps,默认false使用高精度和仅用设备两种定位模式的,参数必须设置为true*/option.setLocationNotify(true);/**可选,设置是否当GPS有效时按照1S/1次频率输出GPS结果,默认false*/option.setIgnoreKillProcess(false);/**定位SDK内部是一个service,并放到了独立进程。设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)*/option.SetIgnoreCacheException(false);/**可选,设置是否收集Crash信息,默认收集,即参数为false*/option.setIsNeedAltitude(true);/**设置海拔高度*/option.setWifiCacheTimeOut(5 * 60 * 1000);/**可选,7.2版本新增能力如果设置了该接口,首次启动定位时,会先判断当前WiFi是否超出有效期,若超出有效期,会先重新扫描WiFi,然后定位*/option.setEnableSimulateGps(false);/**可选,设置是否需要过滤GPS仿真结果,默认需要,即参数为false*/option.setIsNeedAddress(true);/**可选,设置是否需要地址信息,默认不需要*/client.setLocOption(option);/**mLocationClient为第二步初始化过的LocationClient对象需将配置好的LocationClientOption对象,通过setLocOption方法传递给LocationClient对象使用*/}class MyBaiDuMap implements BDLocationListener {@Overridepublic void onReceiveLocation(BDLocation bdLocation) {Latitude = bdLocation.getLatitude();//获取纬度Longitude = bdLocation.getLongitude();//获取经度mLatitude.setText( Latitude+"" );mLongitude.setText( Longitude+"" );double Radius = bdLocation.getRadius();if (bdLocation.getLocType() == BDLocation.TypeGpsLocation || bdLocation.getLocType() == BDLocation.TypeNetWorkLocation){navigateTo(bdLocation);}//StringBuilder currentPosition = new StringBuilder();StringBuilder currentCity = new StringBuilder(  );StringBuilder Position = new StringBuilder(  );//currentPosition.append("纬度:").append(bdLocation.getLatitude()).append("\n");// currentPosition.append("经度:").append(bdLocation.getLongitude()).append("\n");/* currentPosition.append("国家:").append(bdLocation.getCountry()).append("\n");currentPosition.append("省:").append(bdLocation.getProvince()).append("\n");currentPosition.append("市/县:").append(bdLocation.getCity()).append("\n");currentPosition.append("区/乡:").append(bdLocation.getDistrict()).append("\n");currentPosition.append("街道/村:").append(bdLocation.getStreet()).append("\n");*/
//            currentPosition.append("定位方式:");//currentPosition.append( bdLocation.getProvince() );// Position.append( bdLocation.getCity() );Position.append( bdLocation.getDistrict() );Position.append( bdLocation.getStreet() );currentCity.append( bdLocation.getProvince() );currentCity.append( bdLocation.getCity() );currentCity.append( bdLocation.getDistrict() );currentCity.append( bdLocation.getStreet() );/*if (bdLocation.getLocType() == BDLocation.TypeGpsLocation){//currentPosition.append("GPS");}else if (bdLocation.getLocType() == BDLocation.TypeNetWorkLocation){//currentPosition.append("网络");}*//*  currentCity.append( bdLocation.getCity() );*///mUpdatePosition = currentPosition+"";CurrentPosition.setText( currentCity );SignInPosition.setText( Position);//Position = CurrentPosition.getText().toString()+"";//Function_CityName.setText( currentCity );}}private void Listener(){OnClick onClick = new OnClick();SubmitMessage.setOnClickListener( onClick );LocationSignIn_Exit.setOnClickListener( onClick );}class OnClick implements View.OnClickListener{@Overridepublic void onClick(View v) {switch (v.getId()){case R.id.SubmitMessage:ShowPopWindows();break;case R.id.LocationSignIn_Exit:startActivity( new Intent( LocationCheckIn.this,SignIn.class ) );}}}
}

成绩查询界面
采用的是MD的CardStackView,需要实现一个Adapter适配器,此适配器与RecyclerView适配器构建类似
一、创建StackAdapter 适配器

package com.franzliszt.Student.QueryScore;
public class StackAdapter extends com.loopeer.cardstack.StackAdapter<Integer> {public StackAdapter(Context context) {super(context);}@Overridepublic void bindView(Integer data, int position, CardStackView.ViewHolder holder) {if (holder instanceof ColorItemLargeHeaderViewHolder) {ColorItemLargeHeaderViewHolder h = (ColorItemLargeHeaderViewHolder) holder;h.onBind(data, position);}if (holder instanceof ColorItemWithNoHeaderViewHolder) {ColorItemWithNoHeaderViewHolder h = (ColorItemWithNoHeaderViewHolder) holder;h.onBind(data, position);}if (holder instanceof ColorItemViewHolder) {ColorItemViewHolder h = (ColorItemViewHolder) holder;h.onBind(data, position);}}@Overrideprotected CardStackView.ViewHolder onCreateView(ViewGroup parent, int viewType) {View view;switch (viewType) {case R.layout.list_card_item_larger_header:view = getLayoutInflater().inflate(R.layout.list_card_item_larger_header, parent, false);return new ColorItemLargeHeaderViewHolder(view);case R.layout.list_card_item_with_no_header:view = getLayoutInflater().inflate(R.layout.list_card_item_with_no_header, parent, false);return new ColorItemWithNoHeaderViewHolder(view);case R.layout.other_item:view = getLayoutInflater().inflate(R.layout.other_item, parent, false);return new ColorItemViewHolder(view);case R.layout.other_item_thank:view = getLayoutInflater().inflate(R.layout.other_item_thank, parent, false);return new ColorItemViewHolder(view);case R.layout.other_item_note_1:view = getLayoutInflater().inflate(R.layout.other_item_note_1, parent, false);return new ColorItemViewHolder(view);case R.layout.other_item_note_2:view = getLayoutInflater().inflate(R.layout.other_item_note_2, parent, false);return new ColorItemViewHolder(view);default:view = getLayoutInflater().inflate(R.layout.first_semester, parent, false);return new ColorItemViewHolder(view);}}@Overridepublic int getItemViewType(int position) {if (position == 6 ){//TODO TEST LARGER ITEMreturn R.layout.other_item;} else if (position == 7){return R.layout.other_item_thank;}else if (position == 8){return R.layout.other_item_note_1;}else if (position == 9){return R.layout.other_item_note_2;} else {return R.layout.first_semester;}}static class ColorItemViewHolder extends CardStackView.ViewHolder {View mLayout;View mContainerContent;TextView mTextTitle;TextView ClassName1,ClassStatus1,ClassMethod1,ClassFlag1,Credit1,GradePoint1;TextView ClassName2,ClassStatus2,ClassMethod2,ClassFlag2,Credit2,GradePoint2;TextView ClassName3,ClassStatus3,ClassMethod3,ClassFlag3,Credit3,GradePoint3;TextView ClassName4,ClassStatus4,ClassMethod4,ClassFlag4,Credit4,GradePoint4;TextView TitleContent,MoreInfo;public ColorItemViewHolder(View view) {super(view);mLayout = view.findViewById(R.id.frame_list_card_item);mContainerContent = view.findViewById(R.id.container_list_content);mTextTitle =  view.findViewById(R.id.text_list_card_title);TitleContent = view.findViewById( R.id.TitleContent );MoreInfo = view.findViewById( R.id.MoreInfo );ClassName1 =  view.findViewById(R.id.ClassName1);ClassStatus1 =  view.findViewById(R.id.ClassStatus1);ClassMethod1 =  view.findViewById(R.id.ClassMethod1);ClassFlag1 =  view.findViewById(R.id.ClassFlag1);Credit1 =  view.findViewById(R.id.Credit1);GradePoint1=  view.findViewById(R.id.GradePoint1);ClassName2 =  view.findViewById(R.id.ClassName2);ClassStatus2 =  view.findViewById(R.id.ClassStatus2);ClassMethod2 =  view.findViewById(R.id.ClassMethod2);ClassFlag2 =  view.findViewById(R.id.ClassFlag2);Credit2 =  view.findViewById(R.id.Credit2);GradePoint2=  view.findViewById(R.id.GradePoint2);ClassName3 =  view.findViewById(R.id.ClassName3);ClassStatus3 =  view.findViewById(R.id.ClassStatus3);ClassMethod3 =  view.findViewById(R.id.ClassMethod3);ClassFlag3 =  view.findViewById(R.id.ClassFlag3);Credit3 =  view.findViewById(R.id.Credit3);GradePoint3=  view.findViewById(R.id.GradePoint3);ClassName4 =  view.findViewById(R.id.ClassName4);ClassStatus4 =  view.findViewById(R.id.ClassStatus4);ClassMethod4 =  view.findViewById(R.id.ClassMethod4);ClassFlag4 =  view.findViewById(R.id.ClassFlag4);Credit4 =  view.findViewById(R.id.Credit4);GradePoint4 = view.findViewById(R.id.GradePoint4);}@Overridepublic void onItemExpand(boolean b) {mContainerContent.setVisibility(b ? View.VISIBLE : View.GONE);}public void onBind(Integer data, int position) {mLayout.getBackground().setColorFilter( ContextCompat.getColor(getContext(), data), PorterDuff.Mode.SRC_IN);//mTextTitle.setText( String.valueOf(position));if (position == 0){mTextTitle.setText( "2019-2020第一学期");ClassName1.setText( "物联网概论" );ClassStatus1.setText( "必修课" );ClassFlag1.setText( "辅修标记:   主修" );ClassMethod1.setText( "考核方式:   考试" );Credit1.setText( "学分:   3.0" );GradePoint1.setText( "绩点:  3.0" );ClassName2.setText( "应用数学" );ClassStatus2.setText( "必修课" );ClassFlag2.setText( "辅修标记:   主修" );ClassMethod2.setText( "考核方式:   考试" );Credit2.setText( "学分:   3.0" );GradePoint2.setText( "绩点:  2.0" );ClassName3.setText( "大学英语" );ClassStatus3.setText( "必修课" );ClassFlag3.setText( "辅修标记:   主修" );ClassMethod3.setText( "考核方式:   考试" );Credit3.setText( "学分:   3.0" );GradePoint3.setText( "绩点:  1.0" );ClassName4.setText( "军事理论" );ClassStatus4.setText( "选修课" );ClassFlag4.setText( "辅修标记:   主修" );ClassMethod4.setText( "考核方式:   考查" );Credit4.setText( "学分:   2.0" );GradePoint4.setText( "绩点:  3.0" );}else if (position == 1){mTextTitle.setText( "2019-2020第二学期");ClassName1.setText( "电子技术" );ClassStatus1.setText( "必修课" );ClassFlag1.setText( "辅修标记:   主修" );ClassMethod1.setText( "考核方式:   考试" );Credit1.setText( "学分:   4.0" );GradePoint1.setText( "绩点:  3.0" );ClassName2.setText( "C语言程序设计" );ClassStatus2.setText( "必修课" );ClassFlag2.setText( "辅修标记:   主修" );ClassMethod2.setText( "考核方式:   考试" );Credit2.setText( "学分:   2.0" );GradePoint2.setText( "绩点:  4.0" );ClassName3.setText( "大学体育" );ClassStatus3.setText( "必修课" );ClassFlag3.setText( "辅修标记:   主修" );ClassMethod3.setText( "考核方式:   考试" );Credit3.setText( "学分:   1.5" );GradePoint3.setText( "绩点:  3.0" );ClassName4.setText( "音乐鉴赏" );ClassStatus4.setText( "选修课" );ClassFlag4.setText( "辅修标记:   主修" );ClassMethod4.setText( "考核方式:   考查" );Credit4.setText( "学分:   1.5" );GradePoint4.setText( "绩点:  3.0" );}else if (position == 2){mTextTitle.setText( "2020-2021第一学期");ClassName1.setText( "单片机技术应用" );ClassStatus1.setText( "必修课" );ClassFlag1.setText( "辅修标记:   主修" );ClassMethod1.setText( "考核方式:   考试" );Credit1.setText( "学分:   4.5" );GradePoint1.setText( "绩点:  4.0" );ClassName2.setText( "JAVA程序设计" );ClassStatus2.setText( "必修课" );ClassFlag2.setText( "辅修标记:   主修" );ClassMethod2.setText( "考核方式:   考试" );Credit2.setText( "学分:   1.0" );GradePoint2.setText( "绩点:  3.0" );ClassName3.setText( "自动识别技术" );ClassStatus3.setText( "必修课" );ClassFlag3.setText( "辅修标记:   主修" );ClassMethod3.setText( "考核方式:   考试" );Credit3.setText( "学分:   4.5" );GradePoint3.setText( "绩点:  4.0" );ClassName4.setText( "文化地理" );ClassStatus4.setText( "选修课" );ClassFlag4.setText( "辅修标记:   主修" );ClassMethod4.setText( "考核方式:   考查" );Credit4.setText( "学分:   1.0" );GradePoint4.setText( "绩点:  4.0" );}else if (position == 3){mTextTitle.setText( "2020-2021第二学期");ClassName1.setText( "Android程序设计" );ClassStatus1.setText( "必修课" );ClassFlag1.setText( "辅修标记:   主修" );ClassMethod1.setText( "考核方式:   考试" );Credit1.setText( "学分:   1.0" );GradePoint1.setText( "绩点:  4.0" );ClassName2.setText( "无线传感网络技术" );ClassStatus2.setText( "必修课" );ClassFlag2.setText( "辅修标记:   主修" );ClassMethod2.setText( "考核方式:   考试" );Credit2.setText( "学分:   1.0" );GradePoint2.setText( "绩点:  4.0" );ClassName3.setText( "体育" );ClassStatus3.setText( "必修课" );ClassFlag3.setText( "辅修标记:   主修" );ClassMethod3.setText( "考核方式:   考试" );Credit3.setText( "学分:   1.5" );GradePoint3.setText( "绩点:  3.0" );ClassName4.setText( "有效沟通技巧" );ClassStatus4.setText( "选修课" );ClassFlag4.setText( "辅修标记:   主修" );ClassMethod4.setText( "考核方式:   考查" );Credit4.setText( "学分:   1.5" );GradePoint4.setText( "绩点:  3.0" );}else if (position == 4){mTextTitle.setText( "2021-2022第一学期");ClassName1.setText( "物联网概论" );ClassStatus1.setText( "必修课" );ClassFlag1.setText( "辅修标记:   主修" );ClassMethod1.setText( "考核方式:   考试" );Credit1.setText( "学分:   3.0" );GradePoint1.setText( "绩点:  3.0" );ClassName2.setText( "应用数学" );ClassStatus2.setText( "必修课" );ClassFlag2.setText( "辅修标记:   主修" );ClassMethod2.setText( "考核方式:   考试" );Credit2.setText( "学分:   3.0" );GradePoint2.setText( "绩点:  2.0" );ClassName3.setText( "大学英语" );ClassStatus3.setText( "必修课" );ClassFlag3.setText( "辅修标记:   主修" );ClassMethod3.setText( "考核方式:   考试" );Credit3.setText( "学分:   3.0" );GradePoint3.setText( "绩点:  1.0" );ClassName4.setText( "军事理论" );ClassStatus4.setText( "必修课" );ClassFlag4.setText( "辅修标记:   主修" );ClassMethod4.setText( "考核方式:   考查" );Credit4.setText( "学分:   2.0" );GradePoint4.setText( "绩点:  3.0" );}else if (position == 5){mTextTitle.setText( "2021-2022第二学期");ClassName1.setText( "物联网概论" );ClassStatus1.setText( "必修课" );ClassFlag1.setText( "辅修标记:   主修" );ClassMethod1.setText( "考核方式:   考试" );Credit1.setText( "学分:   3.0" );GradePoint1.setText( "绩点:  3.0" );ClassName2.setText( "应用数学" );ClassStatus2.setText( "必修课" );ClassFlag2.setText( "辅修标记:   主修" );ClassMethod2.setText( "考核方式:   考试" );Credit2.setText( "学分:   3.0" );GradePoint2.setText( "绩点:  2.0" );ClassName3.setText( "大学英语" );ClassStatus3.setText( "必修课" );ClassFlag3.setText( "辅修标记:   主修" );ClassMethod3.setText( "考核方式:   考试" );Credit3.setText( "学分:   3.0" );GradePoint3.setText( "绩点:  1.0" );ClassName4.setText( "军事理论" );ClassStatus4.setText( "必修课" );ClassFlag4.setText( "辅修标记:   主修" );ClassMethod4.setText( "考核方式:   考查" );Credit4.setText( "学分:   2.0" );GradePoint4.setText( "绩点:  3.0" );}else if (position == 6){mTextTitle.setText( "毕业设计");}else if (position == 7){mTextTitle.setText( "致谢");}else if (position == 8){mTextTitle.setText( "校园杂记一");}else if (position == 9){mTextTitle.setText( "校园杂记二");}else {mTextTitle.setText( String.valueOf(position));}}}static class ColorItemWithNoHeaderViewHolder extends CardStackView.ViewHolder {View mLayout;TextView mTextTitle;public ColorItemWithNoHeaderViewHolder(View view) {super(view);mLayout = view.findViewById(R.id.frame_list_card_item);mTextTitle = (TextView) view.findViewById(R.id.text_list_card_title);}@Overridepublic void onItemExpand(boolean b) {}public void onBind(Integer data, int position) {mLayout.getBackground().setColorFilter(ContextCompat.getColor(getContext(), data), PorterDuff.Mode.SRC_IN);mTextTitle.setText( String.valueOf(position));}}static class ColorItemLargeHeaderViewHolder extends CardStackView.ViewHolder {View mLayout;View mContainerContent;TextView mTextTitle;public ColorItemLargeHeaderViewHolder(View view) {super(view);mLayout = view.findViewById(R.id.frame_list_card_item);mContainerContent = view.findViewById(R.id.container_list_content);mTextTitle = view.findViewById(R.id.text_list_card_title);}@Overridepublic void onItemExpand(boolean b) {mContainerContent.setVisibility(b ? View.VISIBLE : View.GONE);}@Overrideprotected void onAnimationStateChange(int state, boolean willBeSelect) {super.onAnimationStateChange(state, willBeSelect);if (state == CardStackView.ANIMATION_STATE_START && willBeSelect) {onItemExpand(true);}if (state == CardStackView.ANIMATION_STATE_END && !willBeSelect) {onItemExpand(false);}}public void onBind(Integer data, int position) {mLayout.getBackground().setColorFilter(ContextCompat.getColor(getContext(), data), PorterDuff.Mode.SRC_IN);mTextTitle.setText( String.valueOf(position));mTextTitle.setText( "2019-2020第一学期");itemView.findViewById(R.id.text_view).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {((CardStackView)itemView.getParent()).performItemClick(ColorItemLargeHeaderViewHolder.this);}});}}}

二、绑定适配器

 QueryScoreCardStackView.setItemExpendListener( this );adapter = new StackAdapter( this );QueryScoreCardStackView.setAdapter( adapter );

三、为每一个子项添加背景色

    public static Integer[] COLOR_DATAS = new Integer[]{R.color.color_1,R.color.color_2,R.color.color_3,R.color.color_4,R.color.color_5,R.color.color_6,R.color.color_7,R.color.color_8,R.color.color_9,R.color.color_10,};
 new Handler(  ).postDelayed( new Runnable() {@Overridepublic void run() {adapter.updateData( Arrays.asList( COLOR_DATAS ) );}} ,200);

Android——一个简单的学生管理系统相关推荐

  1. python小项目实例流程-Python小项目:快速开发出一个简单的学生管理系统

    原标题:Python小项目:快速开发出一个简单的学生管理系统 本文根据实际项目中的一部分api 设计抽象出来,实例化成一个简单小例子,暂且叫作「学生管理系统」. 这个系统主要完成下面增删改查的功能: ...

  2. python小项目案例-Python小项目:快速开发出一个简单的学生管理系统

    本文根据实际项目中的一部分api 设计抽象出来,实例化成一个简单小例子,暂且叫作「学生管理系统」. 这个系统主要完成下面增删改查的功能: 包括: 学校信息的管理 教师信息的管理 学生信息的管理 根据A ...

  3. python项目开发实例-Python小项目:快速开发出一个简单的学生管理系统

    本文根据实际项目中的一部分api 设计抽象出来,实例化成一个简单小例子,暂且叫作「学生管理系统」. 这个系统主要完成下面增删改查的功能: 包括: 学校信息的管理 教师信息的管理 学生信息的管理 根据A ...

  4. python简单项目-Python小项目:快速开发出一个简单的学生管理系统

    本文根据实际项目中的一部分api 设计抽象出来,实例化成一个简单小例子,暂且叫作「学生管理系统」. 这个系统主要完成下面增删改查的功能: 包括: 学校信息的管理 教师信息的管理 学生信息的管理 根据A ...

  5. xml解析案例:一个简单的学生管理系统

    1.创建一个xml文件,写一些学生信息 <?xml version="1.0" encoding="UTF-8"?><person> & ...

  6. 面向对象写一个简单的学生管理系统

    package com.xuesheng; //使用面向对象编写一个学生管理系统. //1.学生类属性有:姓名.性别.年龄.班级:学生可以自由选科: //3.在测试类中实例化学生对象,并打印每个学生选 ...

  7. 用python编写学生管理系统_用python写一个简单的学生管理系统

    要求如下:1.一个循环2中输入内容的能力.显示函数添加新名片显示所有查询的名片3退出系统.让用户输入所需的操作,如输入1,2,3,04.新列表提示用户输入名称和输入电子邮件提示成功添加新名片.5.显示 ...

  8. jquery mysql jsp_jsp+jquery+mysql实现的一个简单的学生管理系统

    1 2 3 4 5 6 pageEncoding="utf-8"%> 7 8 9 10 学生管理系统 11 12 href="https://stackpath.b ...

  9. php--实现一个简单的学生管理系统

    1.实例: 2.具体实现: c.php前台页面 <html> <head> <meta http-equiv="content-type" conte ...

最新文章

  1. vue + element +tp5 个人博客后台管理小记
  2. Java jvisualvm简要说明
  3. 使用Postgrest快速创建数据库的OpenAPI接口
  4. opencv对应python版本_【求问各位大佬python3.6怎么使用opencv,用哪个版本】python3 opencv...
  5. 西南交大计算机组成原理考试大纲,西南交大计算机组成原理实验二七段LED数码管显示译码器的设计.docx...
  6. OrderAnalyticsController.initializeCachedDB - jdbc
  7. word List39
  8. 牛客练习赛10 F-序列查询(莫队+链表)
  9. 课时27.base(掌握)
  10. ubuntu14.04 upgrade出现【Ubuntu is running in low-graphics mode】问题的一个解决办法
  11. SQL 创建随机时间的函数
  12. 通过输入方式在Android上进行微博OAuth登录
  13. Unity3D研究院之手游开发中所有特殊的文件夹(转)
  14. 把ipa包上传到AppStore
  15. adb 驱动安装说明文档
  16. 三极管原理-导通条件
  17. python中控脚本_python连接中控考勤机分析数据
  18. php汉字存储容量大小,存储400个24*24点阵汉字字形所需的存储容量是多少
  19. echarts树状图怎么设置主节点和子节点的距离_教你秒懂CAD出图比例正确设置技巧...
  20. Android 性能优化:使用 Lint 优化代码、去除多余资源

热门文章

  1. (附源码)springboot-鑫源停车场管理系统 毕业设计290915
  2. 透视(perspective)
  3. 同为(TOWE)IPS系列工业插头插座、连接器的选型及特点
  4. TVB举行台庆亮灯仪式 帝后大热门黎耀祥邓萃雯抢眼
  5. 辅警对学历有什么要求吗?
  6. 如何组建软件测试团队
  7. 记一次MATLAB/Simulink的光伏板仿真试手
  8. outlook2007不能发送邮件
  9. 运维必备——ELK日志分析系统
  10. Android开发中的一些小知识点记录(101-120)