Advertisement
Guest User

//sajed//27/10/2017

a guest
Oct 27th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.43 KB | None | 0 0
  1. MainActivity
  2. ----------------
  3. package com.example.asusproi5win10.myapplication;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.content.SharedPreferences;
  7. import android.support.v7.app.AppCompatActivity;
  8. import android.os.Bundle;
  9. import android.view.View;
  10. import android.widget.EditText;
  11. import android.widget.Toast;
  12. public class MainActivity extends AppCompatActivity implements View.OnClickListener {
  13.     EditText etUserName, etPassword;
  14. String c;
  15.     @Override
  16.     protected void onCreate(Bundle savedInstanceState) {
  17.         super.onCreate(savedInstanceState);
  18.         setContentView(R.layout.activity_main);
  19.  
  20.         connectToLayout();
  21.     }
  22.  
  23.     private void connectToLayout() {
  24.         etUserName = (EditText) findViewById(R.id.etUserName);
  25.         etPassword = (EditText) findViewById(R.id.etPassword);
  26.  
  27.  
  28.         findViewById(R.id.btnCancel).setOnClickListener(this);
  29.         findViewById(R.id.btnLogin).setOnClickListener(this);
  30.         findViewById(R.id.btnRegister).setOnClickListener(this);
  31.  
  32.     }
  33.  
  34.     @Override
  35.     public void onClick(View view) {
  36.         switch (view.getId()) {
  37.             case R.id.btnLogin:
  38.                 String userName = etUserName.getText().toString();
  39.                 String password = etPassword.getText().toString();
  40.  
  41.  
  42.                 if (userName.length() == 0 || password.length() == 0) {
  43.                     Toast.makeText(this, "Please fill user name and password!", Toast.LENGTH_LONG).show();
  44.                     return;
  45.                 }
  46.  
  47.  
  48.                 if (isValid(userName, password)) {
  49.                     if(isTeasher(password)) {
  50.                         Intent i = new Intent(this, Teasher.class);
  51.                         i.putExtra("CurrentUser", userName);
  52.                         startActivity(i);
  53.                     }
  54.                     else{
  55.                         Intent i = new Intent(this, WelcomeActivity.class);
  56.                         i.putExtra("CurrentUser", userName);
  57.                         startActivity(i);
  58.                     }
  59.  
  60.                 } else {
  61.                     Toast.makeText(this, "Invalid username or password!", Toast.LENGTH_LONG).show();
  62.                 }
  63.                 break;
  64.             case R.id.btnCancel:
  65.                 this.finish();
  66.                 break;
  67.  
  68.             case R.id.btnRegister:
  69.                 userName = etUserName.getText().toString();
  70.                 password = etPassword.getText().toString();
  71.  
  72.                 if (!isUserExist(userName)) {
  73.                     if (addNewUser(userName, password)) {
  74.  
  75.                         Toast.makeText(this, "User was added!", Toast.LENGTH_LONG).show();
  76.                         etUserName.setText("");
  77.                         etPassword.setText("");
  78.                     } else {
  79.                         Toast.makeText(this, "Error adding a user " + userName, Toast.LENGTH_LONG).show();
  80.                     }
  81.                 }
  82.             break;
  83.             default:
  84.                 Toast.makeText(this, "Error on click", Toast.LENGTH_LONG).show();
  85.                 break;
  86.         }
  87.     }
  88.  
  89.    private boolean isTeasher(String password) {
  90.  
  91.         String s = password.substring(0,4);
  92.  
  93.         return (s.equals("0000"));
  94.     }
  95.  
  96.  
  97.     private boolean addNewUser(String userName, String password) {
  98.         SharedPreferences prefs = this.getSharedPreferences("myUsers", Context.MODE_PRIVATE);
  99.  
  100.         SharedPreferences.Editor editor = prefs.edit();
  101.         editor.putString(userName, password);
  102.         return editor.commit();
  103.     }
  104.  
  105.  
  106.     private boolean isUserExist(String userName) {
  107.         SharedPreferences prefs = this.getSharedPreferences("myUsers", Context.MODE_PRIVATE);
  108.  
  109.         String savedPassword = prefs.getString(userName, "");
  110.  
  111.         return (!savedPassword.equals(""));
  112.     }
  113.  
  114.  
  115.     private boolean isValid(String userName, String password) {
  116.  
  117.         SharedPreferences prefs = this.getSharedPreferences("myUsers", Context.MODE_PRIVATE);
  118.  
  119.         String savedPassword = prefs.getString(userName, "");
  120.  
  121.         return (savedPassword.equals(password));
  122.     }
  123. }
  124.  
  125. WelcomeActivity
  126. ----------------
  127. package com.example.asusproi5win10.myapplication;
  128.  
  129. import android.content.Context;
  130. import android.content.SharedPreferences;
  131. import android.database.DataSetObserver;
  132. import android.support.v7.app.AppCompatActivity;
  133. import android.os.Bundle;
  134. import android.view.View;
  135. import android.view.ViewGroup;
  136. import android.widget.ListAdapter;
  137. import android.widget.ListView;
  138. import android.widget.TextView;
  139. import android.widget.Toast;
  140.  
  141. import java.util.ArrayList;
  142. import java.util.List;
  143.  
  144. public class WelcomeActivity extends AppCompatActivity  implements View.OnClickListener{
  145.     private TextView tvWelcome;
  146.     private String userName;
  147.     private ListView lsvGrades;
  148.     @Override
  149.     protected void onCreate(Bundle savedInstanceState) {
  150.         super.onCreate(savedInstanceState);
  151.         setContentView(R.layout.activity_welcome);
  152.  
  153.         userName = getIntent().getStringExtra("CurrentUser");
  154.  
  155.         tvWelcome = (TextView) findViewById(R.id.tvWellcome);
  156.         lsvGrades = (ListView) findViewById(R.id.lsvGrades);
  157.         findViewById(R.id.btnCancel).setOnClickListener(this);
  158.  
  159.         tvWelcome.setText(userName);
  160.  
  161.         //lsvGrades.setAdapter(new GradesAdapter(userName,this));
  162.  
  163.  
  164.     }
  165.  
  166.     @Override
  167.     public void onClick(View view) {
  168.         switch (view.getId()) {
  169.             case R.id.btnCancel:
  170.                 this.finish();
  171.                 break;
  172.             default:
  173.                 Toast.makeText(this, "Error on click", Toast.LENGTH_LONG).show();
  174.                 break;
  175.         }
  176.     }
  177.  
  178.  
  179. }
  180.  
  181.  
  182.  
  183.  
  184. Teasher
  185. --------
  186. package com.example.asusproi5win10.myapplication;
  187.  
  188. import android.app.Dialog;
  189. import android.content.Context;
  190. import android.content.Intent;
  191. import android.content.SharedPreferences;
  192. import android.support.v7.app.AppCompatActivity;
  193. import android.os.Bundle;
  194. import android.view.View;
  195. import android.widget.AdapterView;
  196. import android.widget.ListView;
  197. import android.widget.TextView;
  198. import android.widget.Toast;
  199.  
  200. import java.util.ArrayList;
  201. import java.util.List;
  202.  
  203. import android.os.Bundle;
  204. import android.app.AlertDialog;
  205. import android.content.ClipData;
  206. import android.content.Context;
  207. import android.content.DialogInterface;
  208. import android.content.SharedPreferences;
  209. import android.support.v7.app.AppCompatActivity;
  210. import android.os.Bundle;
  211. import android.view.LayoutInflater;
  212. import android.view.View;
  213. import android.widget.AdapterView;
  214. import android.widget.Button;
  215. import android.widget.EditText;
  216. import android.widget.ListView;
  217. import android.widget.Toast;
  218.  
  219. import java.util.ArrayList;
  220. import java.util.List;
  221. import java.util.Set;
  222.  
  223. import static android.os.Build.VERSION_CODES.M;
  224. import static com.example.asusproi5win10.myapplication.R.id.btnAdd;
  225. import static com.example.asusproi5win10.myapplication.R.id.etGrade;
  226. import static com.example.asusproi5win10.myapplication.R.id.etStudentName;
  227. import static com.example.asusproi5win10.myapplication.R.id.tvItemSubject;
  228. import static com.example.asusproi5win10.myapplication.R.id.tvSubject;
  229.  
  230. public class Teasher extends AppCompatActivity implements View.OnClickListener {
  231.     private TextView tvTeasher;
  232.     private static ListView lsvStudent;
  233.     Context context;
  234.     private static String userName;
  235.  
  236.     @Override
  237.     protected void onCreate(Bundle savedInstanceState) {
  238.         super.onCreate(savedInstanceState);
  239.         setContentView(R.layout.activity_teasher);
  240.         context = this;
  241.         userName = getIntent().getStringExtra("CurrentUser");
  242.  
  243.         lsvStudent = (ListView) findViewById(R.id.lsvStudent);
  244.         tvTeasher = (TextView) findViewById(R.id.tvTeasher);
  245.         findViewById(R.id.btnCancel).setOnClickListener(this);
  246.         findViewById(R.id.btnAdd).setOnClickListener(this);
  247.         tvTeasher.setText(userName);
  248.  
  249.         lsvStudent.setAdapter(new GradeAdapter(userName,this));
  250.  
  251.  
  252.     }
  253.  
  254.  
  255.  
  256.  
  257.     public static void getGrade(final Context context) {
  258.  
  259.         AlertDialog.Builder bldr = new AlertDialog.Builder(context);
  260.         final View v = LayoutInflater.from(context).inflate(R.layout.dialog_add_grade, null);
  261.  
  262.         bldr.setView(v);
  263.         bldr.setTitle("Add New Student");
  264.  
  265.         bldr.setPositiveButton("Save", new DialogInterface.OnClickListener() {
  266.             @Override
  267.             public void onClick(DialogInterface dialog, int which) {
  268.                 String studentName = ((EditText) v.findViewById(R.id.etStudentName)).getText().toString();
  269.                 int grade = Integer.parseInt(((EditText) v.findViewById(R.id.etGrade)).getText().toString());
  270.                 if (!studentName.isEmpty()) {
  271.                     saveGrade(context, studentName, grade);
  272.                 }
  273.  
  274.             }
  275.  
  276.         });
  277.  
  278.         bldr.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  279.             @Override
  280.             public void onClick(DialogInterface dialog, int which) {
  281.                 dialog.dismiss();
  282.             }
  283.         });
  284.  
  285.         bldr.show();
  286.  
  287.     }
  288.  
  289.    private static void saveGrade(Context context, String studentName, int grade) {
  290.  
  291.        SharedPreferences sharedPrefs = context.getSharedPreferences(userName, Context.MODE_PRIVATE);
  292.  
  293.         sharedPrefs.edit().putInt( studentName,grade).commit();
  294.        lsvStudent.setAdapter(new GradeAdapter(userName,context));
  295.  
  296.     }
  297.     private List<Grade> loadFromFile() {
  298.         SharedPreferences sharedPrefs = context.getSharedPreferences(userName, Context.MODE_PRIVATE);
  299.         Object[] keys = sharedPrefs.getAll().keySet().toArray();
  300.  
  301.         List<Grade> lst = new ArrayList<>();
  302.         for (int i = 0; i < keys.length; i += 1) {
  303.             String name = (String) keys[i];
  304.             lst.add(new Grade(name, sharedPrefs.getInt(name, 0)));
  305.         }
  306.         return lst;
  307.     }
  308.  
  309.  
  310.  
  311.     public void onClick(View view) {
  312.         switch (view.getId()) {
  313.             case R.id.btnAdd:
  314.                 getGrade(context);
  315.                 break;
  316.             case R.id.btnCancel:
  317.                 this.finish();
  318.                 break;
  319.             default:
  320.                 Toast.makeText(this, "Error on click", Toast.LENGTH_LONG).show();
  321.                 break;
  322.         }
  323.  
  324.     }
  325.  
  326.  
  327.  
  328. }
  329. GradesAdapter
  330. -------------
  331. package com.example.asusproi5win10.myapplication;
  332.  
  333. import android.content.Context;
  334. import android.content.SharedPreferences;
  335. import android.view.LayoutInflater;
  336. import android.view.View;
  337. import android.view.ViewGroup;
  338. import android.widget.BaseAdapter;
  339. import android.widget.EditText;
  340. import android.widget.ListView;
  341. import android.widget.TextView;
  342. import android.widget.Toast;
  343.  
  344. import java.util.ArrayList;
  345. import java.util.List;
  346.  
  347. import static android.icu.lang.UCharacter.GraphemeClusterBreak.T;
  348. public class GradesAdapter extends BaseAdapter {
  349.     private Context context;
  350.     private String userName;
  351.     private ListView lsvGrades;
  352.     private List<GradeItem> gradesList;
  353.     private static String studentName;
  354.     public GradesAdapter(String userName, Context context) {
  355.         this.userName = userName;
  356.         this.context = context;
  357.         this.gradesList = LoadStudentGrades( userName, context);
  358.  
  359.     }
  360.  
  361.  
  362.     @Override
  363.     public int getCount() {
  364.         return gradesList.size();
  365.     }
  366.  
  367.     @Override
  368.     public Object getItem(int i) {
  369.         return gradesList
  370.                 .get(i);
  371.     }
  372.  
  373.     @Override
  374.     public long getItemId(int i) {
  375.         return 0;
  376.     }
  377.  
  378.     @Override
  379.     public View getView(final int i, View view, ViewGroup viewGroup) {
  380.  
  381.         View rowView = LayoutInflater.from(context).inflate(R.layout.grade_item_layout, null);
  382.         TextView tvSubjectName = (TextView) rowView.findViewById(R.id.tvItemSubject);
  383.         final EditText etGrade = (EditText) rowView.findViewById(R.id.etItemGrade);
  384.         tvSubjectName.setText(gradesList.get(i).getSubjectName());
  385.         etGrade.setText(gradesList.get(i).getGrade() + "");
  386.         LoadStudentGrades( userName, context);
  387.  
  388.  
  389.         return rowView;
  390.     }
  391.  
  392.         private List<GradeItem> LoadStudentGrades (String userName, Context context){
  393.         SharedPreferences gradePrefs = context.getSharedPreferences(userName, Context.MODE_PRIVATE);
  394.         List<GradeItem> res = new ArrayList<>();
  395.  
  396.         Object[] subjects = gradePrefs.getAll().keySet().toArray();
  397.  
  398.         for (int i = 0;  i < subjects.length; i += 1) {
  399.             String subjectName = (String) subjects[i];
  400.             int grade = gradePrefs.getInt(subjectName, 0);
  401.             res.add(new GradeItem(subjectName, grade));
  402.         }
  403.         return  res;
  404.     }
  405.  
  406.  
  407. }
  408.  
  409. GradeAdapter
  410. ------------
  411. package com.example.asusproi5win10.myapplication;
  412.  
  413. import android.content.Context;
  414. import android.content.SharedPreferences;
  415. import android.support.v7.app.AppCompatActivity;
  416. import android.os.Bundle;
  417. import android.view.LayoutInflater;
  418. import android.view.View;
  419. import android.view.ViewGroup;
  420. import android.widget.BaseAdapter;
  421. import android.widget.EditText;
  422. import android.widget.TextView;
  423. import android.widget.Toast;
  424.  
  425. import java.util.ArrayList;
  426. import java.util.List;
  427.  
  428. public class GradeAdapter extends BaseAdapter {
  429.     private Context context;
  430.     private String studentName;
  431.     private String userName;
  432.  
  433.     private List<Grade> lst;
  434.  
  435.     public GradeAdapter(String userName, Context context) {
  436.         this.userName = userName;
  437.         this.context = context;
  438.         this.lst = LoadStudentGrades(userName, context);
  439.  
  440.     }
  441.     @Override
  442.     public int getCount() {
  443.         return lst.size();
  444.     }
  445.     @Override
  446.     public Object getItem(int i) {
  447.         return lst.get(i);
  448.     }
  449.     @Override
  450.     public long getItemId(int i) {
  451.         return 0;
  452.     }
  453.     @Override
  454.     public View getView(final int i, View view, ViewGroup viewGroup) {
  455.         View rowView = LayoutInflater.from(context).inflate(R.layout.activity_grade_adapter, null);
  456.         TextView etStudentName = (TextView) rowView.findViewById(R.id.tvItemStudentName);
  457.         final EditText etGrade = (EditText) rowView.findViewById(R.id.etItemGrade);
  458.         etStudentName.setText(lst.get(i).getStudentName());
  459.         etGrade.setText( lst.get(i).getGrade() + "" );
  460.         LoadStudentGrades( userName, context);
  461.  
  462.         return rowView;
  463.     }
  464.     public static List<Grade> LoadStudentGrades(String userName, Context context) {
  465.         SharedPreferences sharedPrefs = context.getSharedPreferences(userName, Context.MODE_PRIVATE);
  466.         List<Grade> res = new ArrayList<>();
  467.  
  468.         Object[] studentsNames = sharedPrefs.getAll().keySet().toArray();
  469.  
  470.         for (int i = 0; i < studentsNames.length; i += 1) {
  471.             String SName = (String) studentsNames[i];
  472.             int grade = sharedPrefs.getInt(SName, 0);
  473.             res.add(new Grade(SName, grade));
  474.  
  475.         }
  476.         return res;
  477.     }
  478. }
  479.  
  480.  
  481. Grade
  482. -------
  483. package com.example.asusproi5win10.myapplication;
  484.  
  485. public class Grade {
  486.         private String StudentName;
  487.         private int grade;
  488.       public Grade(String StudentName, int grade) {
  489.             this.StudentName = StudentName;
  490.             this.grade = grade;
  491.         }
  492.  
  493.         public String getStudentName() {
  494.             return StudentName;
  495.         }
  496.  
  497.         public void setStudentName(String StudentName) {
  498.             this.StudentName = StudentName;
  499.         }
  500.  
  501.         public int getGrade() {
  502.             return grade;
  503.         }
  504.  
  505.         public void setGrade(int grade) {
  506.             this.grade = grade;
  507.         }
  508.  
  509.  
  510.  
  511. }
  512.  
  513. GradeItem
  514. -----------
  515. package com.example.asusproi5win10.myapplication;
  516. public class GradeItem {
  517.     private String subjectName;
  518.     private int grade;
  519.  
  520.     public GradeItem(String subjectName, int grade) {
  521.         this.subjectName = subjectName;
  522.         this.grade = grade;
  523.     }
  524.  
  525.     public String getSubjectName() {
  526.         return subjectName;
  527.     }
  528.  
  529.     public void setSubjectName(String subjectName) {
  530.         this.subjectName = subjectName;
  531.     }
  532.  
  533.     public int getGrade() {
  534.         return grade;
  535.     }
  536.  
  537.     public void setGrade(int grade) {
  538.         this.grade = grade;
  539.     }
  540.  
  541. }
  542. activity_teasher
  543. -----------------
  544. <?xml version="1.0" encoding="utf-8"?>
  545. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  546.     xmlns:tools="http://schemas.android.com/tools"
  547.     android:id="@+id/activity_teasher"
  548.     android:layout_width="match_parent"
  549.     android:layout_height="match_parent"
  550.     android:paddingBottom="@dimen/activity_vertical_margin"
  551.     android:paddingLeft="@dimen/activity_horizontal_margin"
  552.     android:paddingRight="@dimen/activity_horizontal_margin"
  553.     android:paddingTop="@dimen/activity_vertical_margin"
  554.     tools:context="com.example.asusproi5win10.myapplication.Teasher">
  555.  
  556.     <TextView
  557.         android:id="@+id/tvTeasher"
  558.         android:layout_width="wrap_content"
  559.         android:layout_height="wrap_content"
  560.         android:layout_alignParentEnd="true"
  561.         android:layout_alignParentStart="true"
  562.         android:layout_alignParentTop="true"
  563.         android:layout_marginTop="12dp" />
  564.  
  565.  
  566.     <Button
  567.         android:id="@+id/btnCancel"
  568.         android:layout_width="match_parent"
  569.         android:layout_height="wrap_content"
  570.         android:layout_weight="1.5"
  571.         android:text="Cancel"
  572.         android:textSize="20sp"
  573.         android:layout_alignParentBottom="true"
  574.         android:layout_alignParentStart="true" />
  575.  
  576.     <Button
  577.         android:id="@+id/btnAdd"
  578.         android:layout_width="match_parent"
  579.         android:layout_height="wrap_content"
  580.         android:layout_weight="1.5"
  581.         android:text="Add"
  582.         android:textSize="20sp"
  583.         android:layout_below="@+id/tvTeasher"
  584.         android:layout_alignParentStart="true"
  585.         android:layout_marginTop="19dp" />
  586.  
  587.     <ListView
  588.         android:id="@+id/lsvStudent"
  589.         android:layout_width="match_parent"
  590.         android:layout_height="wrap_content"
  591.         android:layout_below="@+id/btnAdd"
  592.         android:layout_alignParentEnd="true">
  593.  
  594.     </ListView>
  595.  
  596.  
  597. </RelativeLayout>
  598.  
  599. activity_main
  600. ---------------
  601. <LinearLayout
  602.     xmlns:android="http://schemas.android.com/apk/res/android"
  603.     android:layout_width="match_parent"
  604.     android:layout_height="match_parent"
  605.     android:orientation="vertical"
  606.     android:weightSum="1">
  607.  
  608.     <TextView
  609.         android:layout_width="match_parent"
  610.         android:layout_height="wrap_content"
  611.         android:layout_marginTop="15dp"
  612.         android:gravity="center"
  613.         android:text="@string/app_name"
  614.         android:textColor="#000ff0"
  615.         android:textSize="32sp" />
  616.  
  617.     <EditText
  618.         android:id="@+id/etUserName"
  619.         android:layout_width="match_parent"
  620.         android:layout_height="wrap_content"
  621.         android:layout_marginTop="15dp"
  622.         android:hint="UserName"
  623.         android:textSize="24sp" />
  624.  
  625.     <EditText
  626.         android:id="@+id/etPassword"
  627.         android:layout_width="match_parent"
  628.         android:layout_height="wrap_content"
  629.         android:hint="Password"
  630.         android:inputType="textPassword"
  631.         android:textSize="24sp" />
  632.  
  633.     <LinearLayout
  634.         android:layout_width="match_parent"
  635.         android:layout_height="wrap_content"
  636.         android:orientation="horizontal"
  637.         android:layout_weight="0.14">
  638.  
  639.         <Button
  640.             android:id="@+id/btnLogin"
  641.             android:layout_width="wrap_content"
  642.             android:layout_height="wrap_content"
  643.             android:layout_margin="10dp"
  644.             android:layout_weight="1"
  645.             android:text="Login"
  646.             android:textSize="18sp" />
  647.  
  648.  
  649.         <Button
  650.             android:id="@+id/btnRegister"
  651.             android:layout_width="wrap_content"
  652.             android:layout_height="wrap_content"
  653.             android:layout_margin="10dp"
  654.             android:layout_weight="1"
  655.             android:text="Register"
  656.             android:textSize="18sp" />
  657.  
  658.         <Button
  659.             android:id="@+id/btnCancel"
  660.             android:layout_width="wrap_content"
  661.             android:layout_height="wrap_content"
  662.             android:layout_margin="10dp"
  663.             android:layout_weight="2.02"
  664.             android:text="Cancel"
  665.             android:textSize="18sp" />
  666.  
  667.  
  668. </LinearLayout>
  669.  
  670.  
  671. </LinearLayout>
  672.  
  673. activity_welcome
  674. -----------------
  675. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  676.     android:layout_width="match_parent"
  677.     android:layout_height="match_parent"
  678.     android:orientation="vertical"
  679.     android:weightSum="1">
  680.  
  681.     <TextView
  682.         android:id="@+id/tvWellcome"
  683.         android:layout_width="match_parent"
  684.         android:layout_height="wrap_content"
  685.         android:textSize="20sp" />
  686.  
  687.     <ListView
  688.         android:id="@+id/lsvGrades"
  689.         android:layout_width="match_parent"
  690.         android:layout_height="284dp"
  691.         android:layout_weight="0.97">
  692.  
  693.     </ListView>
  694.  
  695.     <Button
  696.         android:id="@+id/btnCancel"
  697.         android:layout_width="match_parent"
  698.         android:layout_height="63dp"
  699.         android:layout_margin="10dp"
  700.         android:text="Cancel"
  701.         android:textSize="18sp" />
  702. </LinearLayout>
  703.  
  704. grade_item_layout
  705. -------------------
  706. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  707.     android:layout_width="match_parent"
  708.     android:layout_height="wrap_content"
  709.     android:background="#00fff0"
  710.     android:orientation="horizontal">
  711.  
  712.     <TextView
  713.         android:id="@+id/tvItemSubject"
  714.         android:layout_width="match_parent"
  715.         android:layout_height="wrap_content"
  716.         android:layout_weight="1"
  717.         android:text="Subject Name"
  718.         android:textSize="20sp" />
  719.  
  720.     <EditText
  721.         android:id="@+id/etItemGrade"
  722.         android:layout_width="match_parent"
  723.         android:layout_height="wrap_content"
  724.         android:layout_weight="1"
  725.         android:inputType="number"
  726.         android:maxLength="3"
  727.         android:text="Grade"
  728.         android:textSize="20sp" />
  729.  
  730. </LinearLayout>
  731. dialog_add_grade
  732. ------------------
  733. <?xml version="1.0" encoding="utf-8"?>
  734. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  735.     android:orientation="vertical" android:layout_width="match_parent"
  736.     android:layout_height="wrap_content">
  737.  
  738.     <EditText
  739.         android:layout_width="match_parent"
  740.         android:layout_height="wrap_content"
  741.         android:id="@+id/etStudentName"
  742.         android:hint="Enter Student..." />
  743.  
  744.     <EditText
  745.         android:layout_width="match_parent"
  746.         android:layout_height="wrap_content"
  747.         android:id="@+id/etGrade"
  748.         android:hint="Enter Grade..." />
  749. </LinearLayout>
  750. activity_grade_adapter
  751. -----------------------
  752. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  753.     android:layout_width="match_parent"
  754.     android:layout_height="wrap_content"
  755.     android:background="#00fff0"
  756.     android:orientation="horizontal">
  757.  
  758.     <TextView
  759.         android:id="@+id/tvItemStudentName"
  760.         android:layout_width="match_parent"
  761.         android:layout_height="wrap_content"
  762.         android:layout_weight="1"
  763.         android:text="Student Name"
  764.         android:textSize="20sp" />
  765.  
  766.     <EditText
  767.         android:id="@+id/etItemGrade"
  768.         android:layout_width="match_parent"
  769.         android:layout_height="wrap_content"
  770.         android:layout_weight="1"
  771.         android:inputType="number"
  772.         android:maxLength="3"
  773.         android:text="Grade"
  774.         android:textSize="20sp" />
  775.  
  776. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement