Creating a dynamic/complex Android viewText + editText layout - android

I'd like to do something a little complex for my android application, and I'm struggling a little.
Overview -
I'm creating a game where the player is given a sentence with some words blanked out, and they must fill in the gaps.
'22 P____ on a F____ P____' becomes '22 Players on a Football Pitch'
'J_____ B_____ is 007' - 'James Bond is 007',
and so forth.
I'm having trouble laying out the textViews + editText's in a way that I like. Their are lots, and lots of these questions - so many that I don't want to hand code a solution.
I want to dynamically create the textViews + the editViews - from the question I pass it. I can create them just fine, it's the adding to the final view I am struggling with - all of the items are bunched into one corner! A linearLayout changes that, but then it's a single element on each line.
I've tried looking online - but I'm not convinced I'm looking at any of the right materials.
What I want is to create something exactly like the picture below (sorry it's so huge) - I think I want to create a wrapper of sorts for all the separate elements (so it lays out nicely) or a make my own custom view class(?) - but I really am unsure of how to progress - so any advice would be great.
Thank you

I had a similar situation where I wanted to have a list of names that would go side-to-side if possible, but if a name was long to begin on the next line.
I played around with a library called android-flowlayout. It has good examples and is fairly easy to customize.

Related

how to create a crossword puzzle shape in android

I want to create a crossword puzzle using android studio. the problem that I run into is I can't figure out a good way to draw the crossword puzzle the crossword
upon selecting a word from that shape. the user will access an interface that is designed specifically for that word. where to enter the answer
The problem I have is how to actually create that crossword shape, especially since I need it to be created dynamically afterwards based on the supplied data.
After 15 days of research all I can find are those possibilities:
Using Table layout with each cell representing a character. But this approach is not appropriate and not optimate and create many problems.
Using GridView with the unused cells set to be invisible. this is better but I think there is a better way than creating Grids only to set most of it to invisible.*
**I am sure there is a better way, but can't figure it out.
I know I have to give a code sample for what I have but I can't even do that till I know what approach I need to create this. If there is any suggestion to make my question clear that will be welcomed as well.
Neither. This calls for custom view for the word grid. While you can probably get it to work without one, it's going to look very amateurish, and you're going to be very hacky. Instead, you'll want a totally custom view doing its own keyboard input handling. Unless this is like a school project where looks and UX don't matter and you just need it done.

Creating Connect4 in Android

I'm trying to create an Android app to play Connect 4 (Four In A Row, etc). As I'm new to Android dev I created a basic Java application to cope with the logic, which plays connect4 using a 2D array and just uses println to print the array to the console which shows the board.
My question is in my game activity what would be the best way to create a 'board' and have it so I can update it to show the position of counters throughout the game; should I create a canvas object, butcher a table layout, or do something else entirely.
Apologies if this is a silly question; I have very limited Android experience.
Many thanks.
As the board is always the same (4x4) you could use a GridLayout with 4 cols and 4 rows. Put an ImageView in every cell and modify it following the players touches.
Agreed, as 4x4 grid could work if that is what you want since you have limited android experience. You can really make a board/grid in multiple ways. I would suggest making sure you know a little about the UI and the android activity lifecycle before you start diving into something. Eventually you will like to add additional UI elements such as score, player's turn etc.
UI:
http://developer.android.com/guide/topics/ui/index.html
Lifecycle:
http://developer.android.com/training/basics/activity-lifecycle/index.html
Here is a grid tutorial instead of opening another view, just update the one with a piece/color or whatever
GridView tutorial:
http://www.androidhive.info/2012/02/android-gridview-layout-tutorial/

Android Design Decision: one layout for multiple activities?

I am new to Android programming, and I need some advice. I want to create an app that teaches children the alphabet and numbers. I want each letter to have their own screen which you can scroll to and from other letters, but each screen will be similar in that it will have the current letter, pictures of objects that start with that letter, and sounds corresponding with the letter and the objects in the background. Should I make one XML layout for these and somehow changed what letter and objects show up in on the layout using Java, make an XML layout per letter, or is there a way to create a base layout in Java and have all of the letters and numbers inherit these qualities and methods. If that is the case, would that require a Java class per letter as well? I am sorry if these seem like stupid questions, but most of my education in Android has come from internet video tutorials. I appreciate any and all help. Thank you for your help in advance!
v> I want each letter to have their own screen which you can scroll to and from other letters, but each screen will be similar
You probably want to check out ViewPager and Fragments for this.
This website usually seems to have pretty good tutorials. The docs and SO usually have good examples of getting started also.
Note These both require API >= 11 or using a compatibility package which you can find a tutorial Here. so that may be something to take into consideration. If that is an issue then you could simply have one layout with TextView, ImageView, etc... which retrieves its data from a DB and load them when a certain event happens such as a click.
Well, if you want a screen for each of the letters that you could swipe to, but each letter is going to have its own set of properties, I recommend you start looking for a ViewPager with custom Fragments. I think that is a good start. Then, you could focus on some other fancy features like sound.

MvxListView in Android with MvvmCross

I'm using MvvmCross v3 and I have a little problem with list in Android.
I actually have a Mvx.MvxListView who works well, but I'm working on tablet, and ListView is a little bit inapropriate. So I want to have a control like WrapPannel in XAML to have more than one item in a row.
How can I have this kind of control?
Thanks
There are two challenges here:
1. Find or make the control you want
The first is really up to you and your UX/design team to do - although people might be able to suggest apps and projects which might help. When choosing a control always be careful to understand it's memory use - especially:
whether it virtualises the UI reusing cells (like a list does)
or whether it creates a cell for every item even if the item is not visible (like a SL WrapPanel does?)
2. Add data-binding to it
This second step is generally quite simple to do - take a look at one of the Mvx layout controls and see how it is converted for databinding - e.g. https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views/MvxLinearLayout.cs
You can generally just cut-and-paste this code over to your new type.
For more on subclassing existing types, also see N=18 in the video series - http://slodge.blogspot.co.uk/2013/05/n18-android-custom-controls-n1-days-of.html - this shows subclassing of a TextView
For a wrappanel, I did previously adapt and use one of #CheeseBaron's ports - FlowLayout - see http://slodge.blogspot.co.uk/2013/01/an-mono-for-android-wrappanelflowlayout.html. However, this has not been updated for v3 - if you do update it, it'd be great if you shared the results back.

android: how to create multiply views screen?

I want to create an activity, which shows a question with 4 answers, and at the bottom of the screen i want to place a timer.
I have already found timer example, and i created a question with the answers. the problem that they are 2 different projects and activities, and i am looking for the best way to implement it. i think i can't show 2 activities on one screen, but i can show 2 views or shell i use the ViewGroup, or maybe to copy-paste one of the activities code to another ( its the easiest way but probably the most ugliest way to implement it).
please tell me what is the best way, that i will study and not to waste time to study all the ways and only then to choose one of them.
welcome to StackOverflow.
You are correct in that you cannot display two activities at once. You must instead look into how layouts work in Android by reading some tutorials on the Android developer guide.
For your layout, I would recommend using a LinearLayout with four TextView objects inside it containing the questions (and perhaps your EditText objects below them) as well as your timer. Make sure they are all inside a ScrollView so the software keyboard doesn't force it all to be squeezed up. This is how I would approach it, but I encourage you to read about how layouts work and use the XML resources.
The Notepad tutorial is an excellent way to get started with views and text entry, as well as using SQLite databases.

Categories

Resources