Android 實例開發(fā)一個學(xué)生管理系統(tǒng)流程詳解
效果演示
隨手做的一個小玩意,還有很多功能沒有完善,倘有疏漏,萬望海涵。

實現(xiàn)功能總覽
實現(xiàn)了登錄、注冊、忘記密碼、成績查詢、考勤情況、課表查看、提交作業(yè)、課程打卡等。
代碼
登錄與忘記密碼界面
登錄與忘記密碼界面采用的是TabLayout+ViewPager+PagerAdapter實現(xiàn)的
一、添加布局文件
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 );
二、添加標(biāo)題文字
private List<String> Titles = new ArrayList<>( );
Titles.add( "首頁" ); Titles.add( "數(shù)據(jù)" ); 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;
}
@Override
public int getCount() {
return Views.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
container.addView( Views.get( position ) );
return Views.get( position );
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView( Views.get( position ) );
}
@Nullable
@Override
public 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 );
注冊界面
一、創(chuàng)建兩個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>
二、將其添加數(shù)組內(nèi)
private final int[] Identity = {R.drawable.press_oval_textview,R.drawable.notpress_oval_textview};
三、動態(tài)變化背景
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] );
}
考勤界面
主要是通過繪制一個圓,圓環(huán)、內(nèi)圓、文字分別使用不同的背景顏色,并將修改背景顏色的接口暴露出來。
一、CircleProgressBar代碼如下
public class CircleProgressBar extends View {
// 畫實心圓的畫筆
private Paint mCirclePaint;
// 畫圓環(huán)的畫筆
private Paint mRingPaint;
// 畫圓環(huán)的畫筆背景色
private Paint mRingPaintBg;
// 畫字體的畫筆
private Paint mTextPaint;
// 圓形顏色
private int mCircleColor;
// 圓環(huán)顏色
private int mRingColor;
// 圓環(huán)背景顏色
private int mRingBgColor;
// 半徑
private float mRadius;
// 圓環(huán)半徑
private float mRingRadius;
// 圓環(huán)寬度
private float mStrokeWidth;
// 圓心x坐標(biāo)
private int mXCenter;
// 圓心y坐標(biāo)
private int mYCenter;
// 字的長度
private float mTxtWidth;
// 字的高度
private float mTxtHeight;
// 總進度
private int mTotalProgress = 100;
// 當(dāng)前進度
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() {
//內(nèi)圓
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);//設(shè)置線冒樣式,有圓 有方
//中間字
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);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw( canvas );
mXCenter = getWidth() / 2;
mYCenter = getHeight() / 2;
//內(nèi)圓
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 );
}
}
//設(shè)置進度
public void setProgress(double progress) {
mProgress = progress;
postInvalidate();//重繪
}
public void setCircleColor(int Color){
mRingPaint.setColor( Color );
postInvalidate();//重繪
}
}
簽到界面
簽到界面就倒計時和位置簽到
一、倒計時
采用的是Thread+Handler
在子線程內(nèi)總共發(fā)生兩種標(biāo)志至Handler內(nèi),0x00表示倒計時未完成,0x01表示倒計時完成。
private void CountDown(){
new Thread( ){
@Override
public 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( ){
@Override
public 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;
@Override
protected 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() );//獲取全局Context
client.registerLocationListener( new MyBaiDuMap() );//注冊一個定位監(jiān)聽器,獲取位置信息,回調(diào)此定位監(jiān)聽器
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 ); //設(shè)置動畫
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() {
@Override
public 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);//允許當(dāng)前設(shè)備顯示在地圖上
}
private void navigateTo(BDLocation location){
if (isFirstLocate){
LatLng lng = new LatLng(location.getLatitude(),location.getLongitude());//指定經(jīng)緯度
MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(lng);
mBaiduMap.animateMapStatus(update);
update = MapStatusUpdateFactory.zoomTo(16f);//百度地圖縮放級別限定在3-19
mBaiduMap.animateMapStatus(update);
isFirstLocate = false;
}
MyLocationData.Builder builder = new MyLocationData.Builder();
builder.latitude(location.getLatitude());//緯度
builder.longitude(location.getLongitude());//經(jīng)度
MyLocationData locationData = builder.build();
mBaiduMap.setMyLocationData(locationData);
}
private void InitPermission(){
List<String> PermissionList = new ArrayList<>();
//判斷權(quán)限是否授權(quán)
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()] );//轉(zhuǎn)化為數(shù)組
ActivityCompat.requestPermissions( LocationCheckIn.this, Permissions, 1 );//一次性申請權(quán)限
} else {
/*****************如果權(quán)限都已經(jīng)聲明,開始配置參數(shù)*****************/
requestLocation();
}
}
//執(zhí)行
private void requestLocation(){
initLocation();
client.start();
}
/*******************初始化百度地圖各種參數(shù)*******************/
public void initLocation() {
LocationClientOption option = new LocationClientOption();
option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
/**可選,設(shè)置定位模式,默認(rèn)高精度LocationMode.Hight_Accuracy:高精度;
* LocationMode. Battery_Saving:低功耗;LocationMode. Device_Sensors:僅使用設(shè)備;*/
option.setCoorType("bd09ll");
/**可選,設(shè)置返回經(jīng)緯度坐標(biāo)類型,默認(rèn)gcj02gcj02:國測局坐標(biāo);bd09ll:百度經(jīng)緯度坐標(biāo);bd09:百度墨卡托坐標(biāo);
海外地區(qū)定位,無需設(shè)置坐標(biāo)類型,統(tǒng)一返回wgs84類型坐標(biāo)*/
option.setScanSpan(3000);
/**可選,設(shè)置發(fā)起定位請求的間隔,int類型,單位ms如果設(shè)置為0,則代表單次定位,即僅定位一次,默認(rèn)為0如果設(shè)置非0,需設(shè)置1000ms以上才有效*/
option.setOpenGps(true);
/**可選,設(shè)置是否使用gps,默認(rèn)false使用高精度和僅用設(shè)備兩種定位模式的,參數(shù)必須設(shè)置為true*/
option.setLocationNotify(true);
/**可選,設(shè)置是否當(dāng)GPS有效時按照1S/1次頻率輸出GPS結(jié)果,默認(rèn)false*/
option.setIgnoreKillProcess(false);
/**定位SDK內(nèi)部是一個service,并放到了獨立進程。設(shè)置是否在stop的時候殺死這個進程,默認(rèn)(建議)不殺死,即setIgnoreKillProcess(true)*/
option.SetIgnoreCacheException(false);
/**可選,設(shè)置是否收集Crash信息,默認(rèn)收集,即參數(shù)為false*/
option.setIsNeedAltitude(true);/**設(shè)置海拔高度*/
option.setWifiCacheTimeOut(5 * 60 * 1000);
/**可選,7.2版本新增能力如果設(shè)置了該接口,首次啟動定位時,會先判斷當(dāng)前WiFi是否超出有效期,若超出有效期,會先重新掃描WiFi,然后定位*/
option.setEnableSimulateGps(false);
/**可選,設(shè)置是否需要過濾GPS仿真結(jié)果,默認(rèn)需要,即參數(shù)為false*/
option.setIsNeedAddress(true);
/**可選,設(shè)置是否需要地址信息,默認(rèn)不需要*/
client.setLocOption(option);
/**mLocationClient為第二步初始化過的LocationClient對象需將配置好的LocationClientOption對象,通過setLocOption方法傳遞給LocationClient對象使用*/
}
class MyBaiDuMap implements BDLocationListener {
@Override
public void onReceiveLocation(BDLocation bdLocation) {
Latitude = bdLocation.getLatitude();//獲取緯度
Longitude = bdLocation.getLongitude();//獲取經(jīng)度
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("經(jīng)度:").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("區(qū)/鄉(xiāng):").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("網(wǎng)絡(luò)");
}*/
/* 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{
@Override
public 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,需要實現(xiàn)一個Adapter適配器,此適配器與RecyclerView適配器構(gòu)建類似
一、創(chuàng)建StackAdapter 適配器
package com.franzliszt.Student.QueryScore;
public class StackAdapter extends com.loopeer.cardstack.StackAdapter<Integer> {
public StackAdapter(Context context) {
super(context);
}
@Override
public 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);
}
}
@Override
protected 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);
}
}
@Override
public int getItemViewType(int position) {
if (position == 6 ){//TODO TEST LARGER ITEM
return 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);
}
@Override
public 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第一學(xué)期");
ClassName1.setText( "物聯(lián)網(wǎng)概論" );
ClassStatus1.setText( "必修課" );
ClassFlag1.setText( "輔修標(biāo)記: 主修" );
ClassMethod1.setText( "考核方式: 考試" );
Credit1.setText( "學(xué)分: 3.0" );
GradePoint1.setText( "績點: 3.0" );
ClassName2.setText( "應(yīng)用數(shù)學(xué)" );
ClassStatus2.setText( "必修課" );
ClassFlag2.setText( "輔修標(biāo)記: 主修" );
ClassMethod2.setText( "考核方式: 考試" );
Credit2.setText( "學(xué)分: 3.0" );
GradePoint2.setText( "績點: 2.0" );
ClassName3.setText( "大學(xué)英語" );
ClassStatus3.setText( "必修課" );
ClassFlag3.setText( "輔修標(biāo)記: 主修" );
ClassMethod3.setText( "考核方式: 考試" );
Credit3.setText( "學(xué)分: 3.0" );
GradePoint3.setText( "績點: 1.0" );
ClassName4.setText( "軍事理論" );
ClassStatus4.setText( "選修課" );
ClassFlag4.setText( "輔修標(biāo)記: 主修" );
ClassMethod4.setText( "考核方式: 考查" );
Credit4.setText( "學(xué)分: 2.0" );
GradePoint4.setText( "績點: 3.0" );
}else if (position == 1){
mTextTitle.setText( "2019-2020第二學(xué)期");
ClassName1.setText( "電子技術(shù)" );
ClassStatus1.setText( "必修課" );
ClassFlag1.setText( "輔修標(biāo)記: 主修" );
ClassMethod1.setText( "考核方式: 考試" );
Credit1.setText( "學(xué)分: 4.0" );
GradePoint1.setText( "績點: 3.0" );
ClassName2.setText( "C語言程序設(shè)計" );
ClassStatus2.setText( "必修課" );
ClassFlag2.setText( "輔修標(biāo)記: 主修" );
ClassMethod2.setText( "考核方式: 考試" );
Credit2.setText( "學(xué)分: 2.0" );
GradePoint2.setText( "績點: 4.0" );
ClassName3.setText( "大學(xué)體育" );
ClassStatus3.setText( "必修課" );
ClassFlag3.setText( "輔修標(biāo)記: 主修" );
ClassMethod3.setText( "考核方式: 考試" );
Credit3.setText( "學(xué)分: 1.5" );
GradePoint3.setText( "績點: 3.0" );
ClassName4.setText( "音樂鑒賞" );
ClassStatus4.setText( "選修課" );
ClassFlag4.setText( "輔修標(biāo)記: 主修" );
ClassMethod4.setText( "考核方式: 考查" );
Credit4.setText( "學(xué)分: 1.5" );
GradePoint4.setText( "績點: 3.0" );
}else if (position == 2){
mTextTitle.setText( "2020-2021第一學(xué)期");
ClassName1.setText( "單片機技術(shù)應(yīng)用" );
ClassStatus1.setText( "必修課" );
ClassFlag1.setText( "輔修標(biāo)記: 主修" );
ClassMethod1.setText( "考核方式: 考試" );
Credit1.setText( "學(xué)分: 4.5" );
GradePoint1.setText( "績點: 4.0" );
ClassName2.setText( "JAVA程序設(shè)計" );
ClassStatus2.setText( "必修課" );
ClassFlag2.setText( "輔修標(biāo)記: 主修" );
ClassMethod2.setText( "考核方式: 考試" );
Credit2.setText( "學(xué)分: 1.0" );
GradePoint2.setText( "績點: 3.0" );
ClassName3.setText( "自動識別技術(shù)" );
ClassStatus3.setText( "必修課" );
ClassFlag3.setText( "輔修標(biāo)記: 主修" );
ClassMethod3.setText( "考核方式: 考試" );
Credit3.setText( "學(xué)分: 4.5" );
GradePoint3.setText( "績點: 4.0" );
ClassName4.setText( "文化地理" );
ClassStatus4.setText( "選修課" );
ClassFlag4.setText( "輔修標(biāo)記: 主修" );
ClassMethod4.setText( "考核方式: 考查" );
Credit4.setText( "學(xué)分: 1.0" );
GradePoint4.setText( "績點: 4.0" );
}else if (position == 3){
mTextTitle.setText( "2020-2021第二學(xué)期");
ClassName1.setText( "Android程序設(shè)計" );
ClassStatus1.setText( "必修課" );
ClassFlag1.setText( "輔修標(biāo)記: 主修" );
ClassMethod1.setText( "考核方式: 考試" );
Credit1.setText( "學(xué)分: 1.0" );
GradePoint1.setText( "績點: 4.0" );
ClassName2.setText( "無線傳感網(wǎng)絡(luò)技術(shù)" );
ClassStatus2.setText( "必修課" );
ClassFlag2.setText( "輔修標(biāo)記: 主修" );
ClassMethod2.setText( "考核方式: 考試" );
Credit2.setText( "學(xué)分: 1.0" );
GradePoint2.setText( "績點: 4.0" );
ClassName3.setText( "體育" );
ClassStatus3.setText( "必修課" );
ClassFlag3.setText( "輔修標(biāo)記: 主修" );
ClassMethod3.setText( "考核方式: 考試" );
Credit3.setText( "學(xué)分: 1.5" );
GradePoint3.setText( "績點: 3.0" );
ClassName4.setText( "有效溝通技巧" );
ClassStatus4.setText( "選修課" );
ClassFlag4.setText( "輔修標(biāo)記: 主修" );
ClassMethod4.setText( "考核方式: 考查" );
Credit4.setText( "學(xué)分: 1.5" );
GradePoint4.setText( "績點: 3.0" );
}else if (position == 4){
mTextTitle.setText( "2021-2022第一學(xué)期");
ClassName1.setText( "物聯(lián)網(wǎng)概論" );
ClassStatus1.setText( "必修課" );
ClassFlag1.setText( "輔修標(biāo)記: 主修" );
ClassMethod1.setText( "考核方式: 考試" );
Credit1.setText( "學(xué)分: 3.0" );
GradePoint1.setText( "績點: 3.0" );
ClassName2.setText( "應(yīng)用數(shù)學(xué)" );
ClassStatus2.setText( "必修課" );
ClassFlag2.setText( "輔修標(biāo)記: 主修" );
ClassMethod2.setText( "考核方式: 考試" );
Credit2.setText( "學(xué)分: 3.0" );
GradePoint2.setText( "績點: 2.0" );
ClassName3.setText( "大學(xué)英語" );
ClassStatus3.setText( "必修課" );
ClassFlag3.setText( "輔修標(biāo)記: 主修" );
ClassMethod3.setText( "考核方式: 考試" );
Credit3.setText( "學(xué)分: 3.0" );
GradePoint3.setText( "績點: 1.0" );
ClassName4.setText( "軍事理論" );
ClassStatus4.setText( "必修課" );
ClassFlag4.setText( "輔修標(biāo)記: 主修" );
ClassMethod4.setText( "考核方式: 考查" );
Credit4.setText( "學(xué)分: 2.0" );
GradePoint4.setText( "績點: 3.0" );
}else if (position == 5){
mTextTitle.setText( "2021-2022第二學(xué)期");
ClassName1.setText( "物聯(lián)網(wǎng)概論" );
ClassStatus1.setText( "必修課" );
ClassFlag1.setText( "輔修標(biāo)記: 主修" );
ClassMethod1.setText( "考核方式: 考試" );
Credit1.setText( "學(xué)分: 3.0" );
GradePoint1.setText( "績點: 3.0" );
ClassName2.setText( "應(yīng)用數(shù)學(xué)" );
ClassStatus2.setText( "必修課" );
ClassFlag2.setText( "輔修標(biāo)記: 主修" );
ClassMethod2.setText( "考核方式: 考試" );
Credit2.setText( "學(xué)分: 3.0" );
GradePoint2.setText( "績點: 2.0" );
ClassName3.setText( "大學(xué)英語" );
ClassStatus3.setText( "必修課" );
ClassFlag3.setText( "輔修標(biāo)記: 主修" );
ClassMethod3.setText( "考核方式: 考試" );
Credit3.setText( "學(xué)分: 3.0" );
GradePoint3.setText( "績點: 1.0" );
ClassName4.setText( "軍事理論" );
ClassStatus4.setText( "必修課" );
ClassFlag4.setText( "輔修標(biāo)記: 主修" );
ClassMethod4.setText( "考核方式: 考查" );
Credit4.setText( "學(xué)分: 2.0" );
GradePoint4.setText( "績點: 3.0" );
}else if (position == 6){
mTextTitle.setText( "畢業(yè)設(shè)計");
}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);
}
@Override
public 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);
}
@Override
public void onItemExpand(boolean b) {
mContainerContent.setVisibility(b ? View.VISIBLE : View.GONE);
}
@Override
protected 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第一學(xué)期");
itemView.findViewById(R.id.text_view).setOnClickListener(new View.OnClickListener() {
@Override
public 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() {
@Override
public void run() {
adapter.updateData( Arrays.asList( COLOR_DATAS ) );
}
} ,200);
到此這篇關(guān)于Android 實例開發(fā)一個學(xué)生管理系統(tǒng)流程詳解的文章就介紹到這了,更多相關(guān)Android 學(xué)生管理系統(tǒng)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Android ExpandableListView展開列表控件使用實例
這篇文章主要介紹了Android ExpandableListView展開列表控件使用實例,本文實現(xiàn)了一個類似手機QQ好友列表的界面效果,需要的朋友可以參考下2014-07-07
Android開發(fā)筆記之:深入理解Cursor相關(guān)的性能問題
本篇文章是對Android中Cursor相關(guān)的性能問題進行了詳細的分析介紹,需要的朋友參考下2013-05-05
Android開發(fā)實現(xiàn)的文本折疊點擊展開功能示例
這篇文章主要介紹了Android開發(fā)實現(xiàn)的文本折疊點擊展開功能,涉及Android界面布局與屬性控制相關(guān)操作技巧,需要的朋友可以參考下2019-03-03
Windows下React Native的Android環(huán)境部署及布局示例
這篇文章主要介紹了Windows下React Native的Android環(huán)境部署及布局示例,這里安卓開發(fā)IDE建議使用Android Studio,且為Windows安裝npm包管理器,需要的朋友可以參考下2016-03-03
Android 判斷SIM卡屬于哪個移動運營商的實現(xiàn)代碼
有時候我們需要在Android中獲取本機網(wǎng)絡(luò)提供商呢,這里簡單分享下,方便需要的朋友2013-05-05
Android開發(fā)之RadioGroup的簡單使用與監(jiān)聽示例
這篇文章主要介紹了Android開發(fā)之RadioGroup的簡單使用與監(jiān)聽,結(jié)合實例形式分析了Android針對RadioGroup單選按鈕簡單實用技巧,需要的朋友可以參考下2017-07-07
Android 接收推送消息跳轉(zhuǎn)到指定頁面的方法
這篇文章主要介紹了Android 接收推送消息跳轉(zhuǎn)到指定頁面的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-01-01

