Android Spinner not optimized or Implementing new Design

Because Android Spinner is not optimized for multiple elements and do not have the desired usability for this use-case,  I decided to implement a new design which use maximum space mobile display. This with changes in database structure, which will lead to new functionalities and more application interactivity from user side, will make a perfect start for a new release of Moldova Public Transport.

Posted in android, Uncategorized | Leave a comment

Moldova Public Transport update

We have new app available! Check the link:

http://androidpositive.info/moldova-public-transport/


 

Mulțumesc p/u folosirea aplicației. Sunt plăcut surprins ca aplicația este utila la multi utilizatori și va mulțumesc p/u comentarii și bug-reports.Chit despre update acesta este un proiect personal si este bazat doar pe entuziasm si timp liber, care din păcate, niciodată nu este destul :) .
La moment se reface baza de date, p/u ca viitoarele update-uri sa meargă mai repede, p/u funcții/rute noii precum si p/u update-uri la ele va fi făcut un serviciu prin care clienții vor putea uploada rutele (coord.) + update-ul va conține versiunea off-line a mapelor de pe OSMaps…

 

Posted in Uncategorized | 23 Comments

Next

Next app will be more complicated and developing process more complex. We will use Tabs, reusable resources, share data between activities, network, parsing website, read and write files etc…
Some screenshots of working application as the proof of the job completed:

Posted in android | 3 Comments

Working with android RadioButtons

Today I’m going to explain the process of developing an android program. For the first example I will take a pretty simple quiz-test application. I assume that you are pretty acknowledged with eclipse or any other IDE and have installed ADT on your computer, besides on internet it’s a lot of information and lessons like how to build a “hello world” app.

Right now I’m eating peaches, so sorry if you find some mistakes…

But let’s start

– below is my requirement:

  • First window will list questions and multiple choices of answers (radio button like)
  • Nice background with scrolling list
  • Second window with the results calculated by the app
  • Options menu for “new test” , “exit” and other stuff

Layout

Our look of the program. As I mentioned, we need a background and some radiobuttons on it. Throw views like imageview, radiobuttons and because we got a lot of content – scrollview in main.xml:

Tip: you can use file valuesstrings.xml for “android:text=”, this will allow in future to modify easily your app.

For the results screen we can create a new activity or do all actions in one activity with “viewflipper”. Android viewflipper is used to add multiple views in a single Flipper – for more explained details look at this example. So now we have “LinearLayout01” and “LinearLayout02” respectively for the first and second window(Fig.1).

First layout should have ScrollView containing the entire contents to scroll (Fig.2) (LinearLayout with Radiobuttons included in Radiogroups):

And add new linearlayout and textview for the second window.

 

 

 

 

Activity JavaCode

Now, let’s start with java coding. For my example I have 23 question with 4 possible answers each. At the end my application must calculate the most common response and depending on it to display that result on the screen. For answer calc. we have

int rasp[]={0,0,0,0};

and assign listener on each radiogroup we have

for ( int i=1;i<23;i++) {

String radiogroupID = "radioGroup" + i;

int gresID = getResources().getIdentifier(radiogroupID, "id", "com.samples.testbaiat");

RadioGroup radioGroup = (RadioGroup) findViewById(gresID);

radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() }

Use case operator for the buttons and increment our variables respectively. At the end find the max value and get the results on screen with viewflipper.

public void onClick(View view) {

// Get the ViewFlipper from the layout

ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);

// Set an animation from res/

vf.setAnimation(AnimationUtils.loadAnimation(view.getContext(), R.anim.push_left_in));

vf.showNext();

//print variables on screen

TextView t2=(TextView) findViewById(R.id.text2);

if (rasp[0]==getMaxValue(rasp)) {

t2.setText(R.string.r1);

} else if (rasp[1]==getMaxValue(rasp)) {

t2.setText(R.string.r2);

} else if (rasp[2]==getMaxValue(rasp)) {

t2.setText(R.string.r3);

} else if (rasp[3]==getMaxValue(rasp)) {

t2.setText(R.string.r4);

}

}

For the options menu use:

 @Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

//"new" option

case R.id.new_test:

Intent myIntent = new Intent(TestBaiatActivity.this, TestBaiatActivity.class);

TestBaiatActivity.this.startActivity(myIntent);

finish();

break;

//"exit option

case R.id.exit:

finish();

break;

}

return true;

}

Conclusion

Output screen:

Of course there are still of plenty room to work with database, saved parameters, loading data from the web, online score screen etc…

But hope you enjoyed this simplest tutorial.

Posted in android | 3 Comments