Reducing or Managing class in Android - android

I am creating a project with 2 SPINNER , When dropdown list of "spinner 1" is clicked it displays 8 Engineering branches and on clicking dropdown list of "spinner 2" Semesters (1st to 8th) are displayed.
If we click any one branch & semester (say Branch - IT, Semester - 3rd) it takes us to new activity with LISTVIEW of Subjects of that semester (here 3rd), If we click any subject it shows the detailed syllabus of the subject.
For performing the above task i will have to create atleast 9*8=72 classes - using INTENT (9 branches & 8 semesters... for entering the subjects of all braches of all semesters). It will to too difficult to manage so many classes and will also take too much time.
My question is:- Is there any way to reduce number of classes?

Related

How to handle a large number of activities in android studio

Iam a student and Iam developing an app for my college for downloading previous year question papers,my college has 14 departments and for each department 8 semesters and in each semester minimum 10 subjects are there so 14*2*8= 1120 java files and XML files I have to create if I keep on intenting from one activity to another it will take a huge time.how handle this huge activities.my app structure would be
Select department(14) >> Select sem(8)>> select subject(10)
Is there any methods like nestedif or something else to reduce the activity files.if there are any methods please do help me to complete the project.thanks in advance
No, you don't need that many activities. You need to write abstract activities that take parameters and displays different data based on those. At most I see 4 activities here- department selector, semester selector, subject selector, and the actual subject activity. And arguably some of those should be fragments instead, although that's more personal choice.

How to make a android app to display questions paper from various stream?

I want to make an app which displays all previous year question papers.... now the problem is...My university has 8 streams to choose and each stream has 8 semesters and each semester has 5 subjects and I want to display papers for each subject when user click on subject name.
Example:-CSE
---Semester 2
---Subject name
----year
Now the problem is... for 8 stream I have to make 8 activities and each stream have 8 semester means again 8 activities for each stream and each semester has 5 subjects so I have to make again 40 activities for each stream and each activity hold various subjects.
So is there any simple way to display all the papers with minimum number of activities.
I am new in programming world so please suggest me simple solution for the question.
Your solution to the above stated problem is static. Try creating a dynamic app wherein you have only one activity for showing the paper. You can pass in the subject code and semester code to the activity when it is created. You can then use that information to fetch the papers that you want to display in that activity from the database or something.
What I mean to say is that, you can have one activity named main_activity wherein you make the user to select the branch and the semester and the subject. Then you can have a button which can be clicked to launch a new activity which shows the paper of the subject that the user selected.
When programming the show papers button, you can use intent to change the activity and can pass some variables to the activity that is going to be created. Something like this -
Intent intent = new Intent(MainActivity.this,ShowPapers.class);
intent.putExtra("Subject_code","CE501");
startActivity(intent);
For show papers activity you can use -
Intent intent = getIntent();
String subject_code=intent.getStringExtra("Subject_code");
Once you have the subject_code, you can fetch the papers for that subject code from the database.
Hope this helps! :)

Arranging categories with sub-categories correctly in Android app?

I am developing an Android app, which has around 6 categories. Every category, has 3 sub-categories each, with same name.
So, how can I arrange the categories in a way, to save long lines of codes. That means less number of activities. Here, I am demonstrating, with an example:
Category 1:
- Add
- Edit
- Delete
Category 2:
- Add
- Edit
- Delete
Category 3:
- Add
- Edit
- Delete
Category 4:
- Add
- Edit
- Delete
Category 5:
- Add
- Edit
- Delete
Category 6:
- Add
- Edit
- Delete
So, I don't want to show the sub-categories "Add-Edit-Delete" six times each for 6 categories, I just want it to be visible for one time on the "Main Activity".
For example,
If I am clicking on "Category 3" - It should ask me on the same activity to "Add or Edit or Delete". Let's say, on clicking, "Add", it should read, "Category 3 - Add" sub-category and rest the procedure goes on.
Can this be possible? I tried with popup-menu, but through this, I have to add "Add-Edit-Delete", separately for each category with separate UI, which isn't good.
What I can do for that?

How many Activities do I need?

I'm in the middle of making my first Android app and have been asked to make an app that displays information on books. I currently have a login screen which brings me to a new page of buttons with different genres. When you click on a genre it brings you to a listview of books in that genre, you then click on a book and it should display information on that book.
My main issue is, I have made a lot a activities already and I'm wondering if I'm going about this the wrong way? When I get to displaying information on each of the books that will be clicked inside of my listview, do I then have to make a new activity for each or is there a better way to do this that I seem to be missing?
Try the following pattern:
Create your first activity for Login (i.e LoginActivity.class)
Create your second activity that contains your genres (i.e GenresActivity.class)
Create your third activity that contains a list of books in that particular genre - remember this will be reused for all genres because it is simply a list of items. (Have you heard of RecyclerView instead of a ListView?)
Create your 4th activity for details of a book (i.e BookDetails.class) - this will also be reused each time to display a book's information. The caveat would be to have the same structure/layout used because a book object has the same information like title, author, year and perhaps cost. So, when a user clicks a book from a list, you want to direct them to a details view where they can view more information on that particular book!
That brings you to 4 activities - not too many if you think about it.
I hope this helps! Good luck!

Make a Highscore Screen in App Inventor

I want to add a Highscore Screen to my Quiz App. I've already created a Highscore Screen with a start value, which contains the score the user has reached in the last round, the category-name and the difficulty.
I split this start value into 2 variables:
The first contains only the score and the other one the category and the difficulty. Now all in all I have 3 categories and 2 difficultys for each of them. Now I want to keep the top 10 Highscores of each category and difficulty. Like this:
Category 1 Difficulty 1
Category 1 Difficulty 2
Category 2 Difficulty 1
Category 2 Difficulty 2
Category 3 Difficulty 1
Category 3 Difficulty 2
As you can see, I will have 6 different Highscore lists.
Now my question:
How can I save all of the 6 lists in my TinyDB and reload the data again?
for each of the lists use its own tag for TinyDB
to save one of the lists, use the TinyDB.StoreValue block, to get it again in Screen.Initialize use the TinyDB.GetValue block, see also the docu and remember: on first run TinyDB is empty, see an example here how to handle that.
and: do the tutorials to get familiar with the basic concepts of App Inventor.

Categories

Resources