Day 3
Dear Friends
Today we just gonna create a simple application in Android that can take 5 names input in 5 different EditText and then on button click program will show names in sorted fashion in those EditText.
for ex
E1 -> anil
E2 -> sunil
E3 -> akhilesh
E4 -> aditya
E5 -> kittu
E6 -> tillu
So after pressing button output of program would be
E1 -> Aditya
E2 -> akhilesh
E3 -> anil
E4 -> kittu
E5 -> sunil
E6 -> tillu
Simple right ? 🙂
Solution :
Approach we can take:
In java you must have heard term like String Array.
Now every name is a string. So we will be having a String array to hold names.
String [ ] inputArray = new String [5];
So in our activity we will be having a method that will read data into inputArray on the click of Button.
String str = ed.getText().toString();
and this str would be then added to inputArray.
Doing this for all the five EditTexts we will be having a String Array that is populated after clicking button.
Now we sort this array and store back results in some auxiliary array or same array.
After this, result can again be used to populate Edittexts to show in UX.
Output image.
Homework
Smriti has many friends which are categorised in different study groups. Please help Smriti’s mother to find Smriti if she is present in particular group.
Group 1 -> [akash,subash,devesh,manoj,kushal]
Group 2 -> [brijesh,suresh,pinkesh,mitali,sonal]
Group 3-> [Smriti, Gurvir,Rajan,Rahul,Pooja]
Group 4->[Chandan,Rachit,Birender,Divya,Geeta]
Write an android application using Edittexts and Textviews to take input as a name of Smriti and there is button that can be clicked to show results.
Cheers ! Now we are playing with Android Programming.