• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Beginner -- Are Activities in Android development akin to Forms in C#, Panels in Java, etc.?

Starsy

Lurker
Jul 22, 2013
2
0
I'm just getting started with Android development after having extensive experience with C#, VB, Java, etc. I'm trying to wrap my mind around the workings of it before moving forward to make sure I'm approaching things correctly.


Right now, I conceptualize of an Activity in Android as similar to a Panel in Java, a Form in C#: a layout/UI with interactive elements and code that responds to those elements.


Is that the right way to think about it?


The app I'm developing to learn the system is a basic flashcard app. After opening the app, you'll be able to choose to Load some flashcards, Create new cards, or Copy other cards. I'm thinking that my home Activity would be three buttons, one for each task, and each button would launch an Activity for each of those tasks - Loading, Creating, or Copying. Would that be the right way to think about this?
 
Makes sense. Any guidance on the best way to go about updating the screen within an Activity, then? Like I said, I'm working on a flashcard app just for practice, so I'm figuring I'll have an Activity specifically for running through a given set of cards. Within those individual cards, though, I figure sometimes I'll have the front of the card showing, sometimes the back, and a button on the bottom to either flip the card or proceed to the next card. I'm figuring I wouldn't have a separate Activity for each card (or maybe I would, a card Activity that can be instantiated separately for each card), but I haven't seen anything yet about dynamically responding in the same Activity.

Not looking for a detailed explanation, just at the overall concept I should be looking for.
 
Upvote 0
Yeah you could wrap stuff up in if/else statements and sorta do something like this.

Code:
Bitmap bitmapImage=BitmapFactory.decodeFile(path);
       ImageView image=(ImageView)findViewById(R.id.image);
       image.setImageBitmap(bitmapImage);

You could put something like that in an onClick or whatevr method your button calls.

Thats a tiny snippet of a code for having users pick their own image, but you could work something that to pull it from an assets folder. Where "image" is the imageview in the XML(R.id.image refers to the id you give it in xml), and "bitmapImage" is your picture.

you could do that same with text
Code:
else if (item.getTitle().toString().equalsIgnoreCase("next")){
                TextView view = (TextView) findViewById(R.id.tv1);
                view.setText("new text");
            }

stuff like that.

Android has a pretty cool cardflip layout transition you should look into too. give it a real card flip feel.

There's a bunch of different ways you could do it though.
 
  • Like
Reactions: Starsy
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones