Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to develop a student management system with Android

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to develop a student management system with Android". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Effect demonstration

Make a gadget easily, there are still many functions are not perfect, if there are omissions, Wanwang Haihan.

Implementation function overview

It realizes login, registration, forgetting password, score query, attendance situation, class schedule view, submission of homework, course clocking in and so on.

Code login and forgot password interface

The login and forgotten password interface is implemented by TabLayout+ViewPager+PagerAdapter.

First, add the layout file View View_HomePager = LayoutInflater.from (Student.this). Inflate (R.layout.homeppagetemporitempagetemptemparentitemparentitempagetemptemparampagetemptemparentificalfalse); View View_Data = LayoutInflater.from (Student.this). Inflate (R.layout.dataformitemtemtemlage) false); View View_Course = LayoutInflater.from (Student.this). Inflate (R.layout.homeppagetemporitemtemparentitionnullcorefalse); View View_My = LayoutInflater.from (Student.this). Inflate (R.layout.myroomitemtemtemparentlfalse) Private List Views = new ArrayList (); Views.add (View_HomePager); Views.add (View_Data); Views.add (View_Course); Views.add (View_My); II. Add the title text private List Titles = new ArrayList (); Titles.add ("home page"); Titles.add ("data"); Titles.add ("course"); Titles.add ("my") The code for binding the adapter / * PagerAdapter adapter is as follows: * / public class ViewPagerAdapter extends PagerAdapter {private List Views; private List Titles; public ViewPagerAdapter (List Views,List 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); Registration interface

First, create two Drawable files

One of them

Second,

Second, add it to the array private final int [] Identity = {R.drawable.pressvalovalidated textviewview}; third, dynamically change the background 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]) } attendance interface

Mainly by drawing a circle, the circle, the inner circle and the text use different background colors, and the interface to modify the background color is exposed.

1. The CircleProgressBar code is as follows: public class CircleProgressBar extends View {/ / Brush private Paint mCirclePaint; / / Brush private Paint mRingPaint; / / Brush background Color private Paint mRingPaintBg; / / Brush private Paint mTextPaint; / / Circle Color private int mCircleColor; / / Ring Color private int mRingColor; / / Ring background Color private int mRingBgColor / / Radius private float mRadius; / / Ring Radius private float mRingRadius; / / Ring width private float mStrokeWidth; / / Center x coordinate private int mXCenter; / / Center y coordinate private int mYCenter; / / length of word private float mTxtWidth; / / height of word private float mTxtHeight; / / Total progress private int mTotalProgress = 100 / / current progress 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 () {/ / inner circle mCirclePaint = new Paint (); mCirclePaint.setAntiAlias (true); mCirclePaint.setColor (mCircleColor); mCirclePaint.setStyle (Paint.Style.FILL) / / Outer arc background mRingPaintBg = new Paint (); mRingPaintBg.setAntiAlias (true); mRingPaintBg.setColor (mRingBgColor); mRingPaintBg.setStyle (Paint.Style.STROKE); mRingPaintBg.setStrokeWidth (mStrokeWidth); / / Outer arc mRingPaint = new Paint (); mRingPaint.setAntiAlias (true); mRingPaint.setColor (mRingColor); mRingPaint.setStyle (Paint.Style.STROKE) MRingPaint.setStrokeWidth (mStrokeWidth); / / mRingPaint.setStrokeCap (Paint.Cap.ROUND); / / sets the line run style, with the round square / / middle word 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; / / Inner canvas.drawCircle (mXCenter, mYCenter, mRadius, mCirclePaint); / / Outer arc background 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, 0360, false, mRingPaintBg) / / the elliptical object in which the arc is located, the starting angle of the arc, the angle of the arc, whether to display the radius line / / outer arc 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); / font String txt = mProgress + "%"; mTxtWidth = mTextPaint.measureText (txt, 0, txt.length ()) Canvas.drawText (txt, mXCenter-mTxtWidth / 2, mYCenter + mTxtHeight / 4, mTextPaint);}} / / set progress public void setProgress (double progress) {mProgress = progress; postInvalidate (); / / redraw} public void setCircleColor (int Color) {mRingPaint.setColor (Color); postInvalidate (); / / redraw}} check-in interface

Check in on the countdown and location of the check-in interface

I. countdown

Using Thread+Handler

A total of two flags occur within the child thread to Handler. 0x00 indicates that the countdown is not complete, and 0x01 indicates that the countdown is complete.

Private void CountDown () {new Thread () {@ Override public void run () {super.run (); for (int j = 14; j > = 0; Jmuri -) {for (int I = 59; I > = 0; iMub -) {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 >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report