1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

Discussion in 'Android Development' started by Starsy, Jul 22, 2013.

  1. Starsy

    Starsy Lurker
    Thread Starter

    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?
     

    Advertisement

  2. out of ideas

    out of ideas Android Enthusiast

    Yeah pretty much.

    Most layout/UI stuff is done with XML file that corresponds to the Activity where all the code is.
     
    Starsy likes this.
  3. Starsy

    Starsy Lurker
    Thread Starter

    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.
     
  4. out of ideas

    out of ideas Android Enthusiast

    Yeah you could wrap stuff up in if/else statements and sorta do something like this.

    Code (Text):
    1. Bitmap bitmapImage=BitmapFactory.decodeFile(path);
    2.        ImageView image=(ImageView)findViewById(R.id.image);
    3.        image.setImageBitmap(bitmapImage);
    4.  
    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 (Text):
    1.  
    2. else if (item.getTitle().toString().equalsIgnoreCase("next")){
    3.                 TextView view = (TextView) findViewById(R.id.tv1);
    4.                 view.setText("new text");
    5.             }
    6.  
    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.
     
    Starsy likes this.
Loading...

Share This Page

Loading...