Android GridView - android

I can't understand how this works in Android. I traversed samples and have no idea. For instance I need 2x2 grid view of TextView widgets. How to write needed code?

You can change the android developer example, on how to create a GridView, to meet your requirements.
Here's the full example.
Also if your beginning Android this would be a good book for you.

Related

android table with more than one column like iOS collectionView

is there a custom UI element on android that will behave like iOS collection view?
[like a grid view, that is scrollable]
or do I have to make a custom table layout custom cells that behave like columns?
here a shot of a UICollectionView for iOS
is there an example for this?
thanks!
Since the previous answer does not reflect performance issues, such as it does not use recycling (which is important for long lists), here is what you are probably looking for:
GridView if your building blocks are all equal in size
http://developer.android.com/guide/topics/ui/layout/gridview.html
or ListView (and a lot of custom logic) if your building blocks have different sizes/widths
http://developer.android.com/guide/topics/ui/layout/listview.html
I don't know the collection view in iOS, but I guess TableLayout is what you are looking for.
https://developer.android.com/reference/android/widget/TableLayout.html
In API14+ there is GridLayout as well.
https://developer.android.com/reference/android/widget/GridLayout.html
Gridview is best replacement of Collection View of IOS. following URL will solve your problem.
http://developer.android.com/guide/topics/ui/layout/gridview.html
This is old, but the Google team have created a widget used in the IO 2014 app that's perfect. It allows for variable column rows and even headers out of the box.
https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/widget/CollectionView.java
You'd have to dig through the source for how it's used, but it's really easy and great to use.
Nowadays RecyclerView is what you're looking for. GridView and others are considered legacy API now. RecyclerView is able to handle these type of layouts more efficiently.

Custom Android GridView

I want to create a GridView like this one:
But, I don't know how! I know how work with Android GridView, but not like this one.
Suggestions of library or any tip will be welcome.
Thanks.
I want to create a GridView like this one
The View you are referring to can quite easily be created without using a GridView. If your components (clothing, bags, shoes etc.) are static, you can use nested LinearLayouts (with weights) inside a ScrollView.
Suggestions of library or any tip will be welcome.
You can try StaggeredGridView: Link
A demo project to get you going: Link

How to realize the layout in android?

data1 hello hi
data2 hello2 hi
data3 hi Hello
I want to konw what should be use,TableLayout?linearLayout or RelativeLayout?Which view realize the layout will more better?I also want to use XML code realize this layout,ask you for help,thank you!
Do you need anything to move around ? Interact with any of the objects?
If you just want something that simple, you can use the TableLayout. If you only need to support ICS (Android 4.0) and later, you can also checkout GridLayout.
LinearLayout is probably not your best choice in terms of performance (will do a lot of calculations for not much). If you have a lot of elements in your table, RelativeLayout is not best either.
You can also check this answer about TableLayout from a Google employee.
IT all depends entrely upon the GUI you want to design, how you want to place your GUI obejcts. The Android official site has a very informative and helpful tutorial on this topic:
http://developer.android.com/guide/topics/ui/declaring-layout.html
http://developer.android.com/guide/topics/ui/declaring-layout.html#CommonLayouts

Custom Android Layouts

I have an upcoming project that requires me to make a custom layout. I have been looking all over for a way to complete this but with no success. The layout will have custom buttons that need to fit the screen and some other custom views. In other words I need it to look the same on all types of devices. So these custom views need to stretch to fit the screens. Something similar to the weather bug app but the buttons will be at the top and there won't be so many options. The buttons will fit the screen width wise. Basically the layout will not contain any stock UI.
I would like to have a book or tutorial that I could follow to help me out here.
check out this blog: http://blog.stylingandroid.com/
there are a lot of good examples for every kind of layout manager in Android.
Furthermore I strongly recommend to you to have a look in the Android's API Demo and source code.
For creating custom view, that's the best resource: http://developer.android.com/guide/topics/ui/custom-components.html
good luck!

Building an Android button with pictures and text

I am looking to build a button in my Android app which must contain:
A background picture
A picture
Some text
I am coming from iPhone dev and I am a little bit confused by Android development.
While I could addSubView: UIImageView or UILabel to my UIButton, I can't use addView() with a android.widget.Button :(
Does anyone have a solution?
EDIT : Thanks everybody for answers. I forgot to specify I have to do it programmatically, without using XML. I don't know how many element I will display (it depends on RSS).
android:background for background ... remeber that you can build your own 9 patch
android:drawableLeft, android:drawableRight, android:drawableTop, android:drawableBottom to add some picture to the left, right, ... of text
EDIT: i didn't mention ... but i was talking about android.widget.Button
2nd EDIT: after you provide more information i think that all what you need is ListView
check this sample http://esilo.pl/LooserSample.zip (don't take "looser" to yourself, it was sample for another guy)
it showing how to
download a JSON data
store it in db
build ContentProvider for sharing a data
use ContentProvider to take data from db and show it in ListView
dynamic loading images from internet
for simpler sample use your sdk samples like this C:\android\android-sdk-windows\samples\android-8\ApiDemos\src\com\example\android\apis\view\List*.java
if you alrady have code for downloading and storing data from RSS in array extend ArrayAdapter to fit your needs
Most, if not all, of the UI for android is built in the XML. Kind of like the UI builder in Xcode, but not near as advanced. The ADP will let you view the UI you have built in Eclipse, and adjust some basic widget properties.
I believe for what you are trying to do, if I understand right, you need to use an ImageButton widget. This widget allows you to use a complete image as a button. You can also define your own states (button pressed, gain focus, etc) with both the button and image button widgets. You can define a background and add images to both widgets.
More information here

Categories

Resources