David
David

Reputation: 303

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

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?

Upvotes: 0

Views: 144

Answers (1)

Boardy
Boardy

Reputation: 36205

You are correct, an activity is a screen that the user will be presented which will consist of user interface elements such as edit texts, text views button etc that the user can interact with.

The activity will load up an XML file which will contain the user interface elements and the layout of how the contents of the activity should be displayed. This XML file is found in res > layout.

Its quite common for your layouts xml file to be the same as the activity name, i.e if you have an activity called MainActivity then you would have a layout file called main_activity.xml.

Then in the activities onCreate method you would use setContentView(R.layout.main_activity);

Hope this helps

Upvotes: 1

Related Questions