[Library] Simple GridLayout - IDEs, Libraries, & Programming Tools

Often we find ourselves messed up with simple things such as layouts.
So I made this library modifying AOSP code to help put items in a Grid Layout.
You can add this as a library or put it separately into your package since it consists of just a single Java file.
Its pretty simple and extremely easy to use. Just put the items in xml between the following tags:
Code:
<tk.eatheat.gridlayout.GridLayout>
....
</tk.eatheat.gridlayout.GridLayout>
By default, it creates a 3x3 grid. To change it just set the number of rows and columns in these lines:
Code:
static private final int COLUMNS = 3;
static private final int ROWS = 3;
Here's a sample app made with the library to show the result.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Click to expand...
Click to collapse
Sample app can be found here.
Library can be found here on my Github here.
-------------------------------
Featured on Portal:
http://www.xda-developers.com/android/simple-gridlayout/

Hey, cool library.
Thanks. :good:

I recently started hobby android app development and this was the thing that always bothered me the most !
Thanks a ton ! this saves me a lot of effort and simplifies everything

sheennick123456 said:
I recently started hobby android app development and this was the thing that always bothered me the most !
Thanks a ton ! this saves me a lot of effort and simplifies everything
Click to expand...
Click to collapse
You are welcome. Glad to be of help.

EatHeat said:
You are welcome. Glad to be of help.
Click to expand...
Click to collapse
Could you add activity starter to buttons?
Sent from my GT-S5570I using xda app-developers app

@m4RinKo2
Code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(newComponentName("com.package.app","com.package.app.ExampleActivity"));
startActivity(intent);
Set intent on the buttons with the correct package and activity names.

Thanks for your hard-work.
This library will be surely somewhere used by me.
Sent from my GT-I9300 using XDA Premium 4 mobile app

Nice lib brother I have a question before importing it to my project how can we add Item click listener so that if i have a list of images in grid i can select one image from that silly question plz help @EatHeat

Related

SpoonDo! - a small utility for managing Outlook Tasks

Hi all,
I created a small tool that wraps the Outlook tasks in a finger friendly UI.
I'm using tasks a lot, and using the 'SpoonDo!' I can see them in categories, sorted by their due dates.
The navigation between categories is simple and on top of that, there's a special fictive category with all the urgent tasks.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Let me know what you think!
Download CAB
More information in the Mobile Spoon blog.
Enjoy!
--------------
If phones were super heroes - how would they look like?
- Iron Man
- Hulk
- Silver Surfer
--------------
Seems nive and useful! I'll try it!
Thanks gil.
EDIT: The download link in the page you reported points to SpoonXMLEditor.
EDIT: I tried the download image and it works.
Marshall
this is very nice and i like it ! although my ThumbCal has a fingerfriendly taskmanagment and im not sure if i need another one.
Any chance of changing language, maybe with a txt-file ?
Thanks.
I guess I can make it localizable.
There's a list of improvements I would like to perform, I will include it as well.
Was unusable...
Just tried to install it on my Diamond....
I have around 250 tasks, it took over a minute just to get into the program...
Wow!
Wow! Such a cool app! Really finger-friendly and a very nice replacement for the Outlook Mobile Tasks... Thx!
Yet I have one question:
Is there a way to edit the categories?
When creating a new task it is possible to create a new category as well but deleting categories seems to be impossible...!
Is there a way to do that?
And then I figured out that if you use commas "," in the category name the category will be split into two (or more) categories in Outlook where the the first name is the part left of the comma and the second name is the part right of the comma. A little bug?

[GUIDE] Defining/Creating Triggering Actions Gestures easier

Hi folks!
This thread will guide you on how you can make your own gestures for triggering actions of your likes. A lot simpler and a lot easier.
Triggering actions has been made possible thanks to:
Tungstwenty - for his "[Ref][Kernel]Triggering actions with touch gestures"
gokhanmoral - for his Amazing Siyahkernel
So let's proceed to the guide..
As we know our screen resolution is 800x480. So if we try to divide the screen into 160x160 boxes this is how it will look like:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Each box I have labeled it with its corresponding minimum and maximum x and y coordinates.
For example we want to create a gesture that is letter S.
Then we would like to define the coordinates of this boxes.
Referring to our 1st picture with the corresponding minimum and maximum x and y coordinates, each boxes according to no. will have this values:
1= 320|480,0|160
2=0|160,0|160
3=0|160,320|480
4=320|480,320|480
5=320|480,640|800
6=0|160,640|800
So if we would want to create the code for our gesture 1 it would look like:
Code:
# Gesture 1 - S
1:1:(320|480,0|160)
1:1:(0|160,0|160)
1:1:(0|160,320|480)
1:1:(320|480,320|480)
1:1:(320|480,640|800)
1:1:(0|160,640|800)
I hope you guys like it! I was so impressed with this feature that I was bored and tried to put a little effort on trying to make the gesture creation easier.
Again, this is just a guide on how you could make gestures easier. If you want to know the full details of what this guide is about, please go to tungstwenty's thread. Thank you!
And if you appreciate my help, just press the thank you button. :highfive:
Thanks for a great visual guide on how to do it :good:
Wonderful ! Thank you
HI,
can you provide a guide for gs3??
thanks
gaetanolip said:
HI,
can you provide a guide for gs3??
thanks
Click to expand...
Click to collapse
ok, I will when I got vacant time.
INDEXED in [INDEX of GUIDES/TUTORIALS] SGS2 GT-I9100 [31/08/2012]
Any Doubt, please don't hessitate to ask.
pelpa87 said:
INDEXED in [INDEX of GUIDES/TUTORIALS] SGS2 GT-I9100 [31/08/2012]
Any Doubt, please don't hessitate to ask.
Click to expand...
Click to collapse
thanks

Play Cards Grid View [GitHub Source Added]

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
GitHub- Source
Hey Guys i was fiddling around with the PlayView developed by GadgetCheck and thought it would be nice to recreate the whole Google Market Layout so that's what i did . Soon i realised the easiest way to implement Card like layout of Google Play was using a 9 patch drawable. During the process i also observed that the market listview had different no of cards for various screen orientations and resolutions like an auto adjust gridview . So it seemed that Every Single Listitem was holding a variable no of cards according to the dimensions of the screen that's when the Bucket-ListAdapter came into play . This is an adapter contributed by rzsombor at GitHub similar to what you see in the Google Play application. It features a grid-like layout of list elements, with the advantage that you can still use list headers and footers - something that's not possible with the standard GridView.The market like PagerSlidingTabStrip have already been implemented by astuetz . So In an hour or so i was ready with my implementation of the Android Market .
Listview with Simple ListAdapter
Listview with Bucket-ListAdapter
Listview with Bucket-ListAdapter Emulating GridView
GitHub Projects Used
Bucket-ListAdapter
Pager-SlidngTabStip
GitHub- Source-PlayCardsGrid
Note :
The bucket-List Adapter is still a work in progress and there are optimization issues .The adapter does not use recycling of views. Neither does it use the viewHolder pattern. So, it is very likely that the app will go out of memory if the number of items in list goes high. Also, the rendering of the items is very slow and the scrolling is not much smooth. We need to work on it to optimize it. Any Developers who wish to Contribute can fork the project and Share their implementation of the Bucket List Adapter in this thread.
Thanks . Happy Coding !
how to implement context menu on the items?
cHu-X said:
how to implement context menu on the items?
Click to expand...
Click to collapse
Its super simple to implement context menu on items. Register a onClickListener on the Overflow ImageView and start a PopupMenu when the overflow icon is clicked. That's it..hope it helped. Also you can now check the code on GitHub. I have added a GitHuB repo for PlayCards GridView
Here you go. :angel:
GitHub - Source

[Q] Set BackgroundColor but keep onTouch

Hello,
I want to set the BackgroundColor of ListView items, but I want to keep the color which appears when I click the items.
How can I do that?
Auroratic said:
Hello,
I want to set the BackgroundColor of ListView items, but I want to keep the color which appears when I click the items.
How can I do that?
Click to expand...
Click to collapse
Rather than replace a "stateListDrawable" with a color or static drawable, replace it with another state list that has the "states" you require
deanwray said:
Rather than replace a "stateListDrawable" with a color or static drawable, replace it with another state list that has the "states" you require
Click to expand...
Click to collapse
I've got it, but I have one problem: The colour on state_pressed should be the default system colour (this one: android.R.drawable.list_selector_background)
How can I do that?
Auroratic said:
I've got it, but I have one problem: The colour on state_pressed should be the default system colour (this one: android.R.drawable.list_selector_background)
How can I do that?
Click to expand...
Click to collapse
I'm not sure what your asking, if you have read about stateListDrawabes and have understood it, also maybe even looked at examples, then you should know ? Open that resource, or even clone it and edit it how you want.
deanwray said:
I'm not sure what your asking, if you have read about stateListDrawabes and have understood it, also maybe even looked at examples, then you should know ? Open that resource, or even clone it and edit it how you want.
Click to expand...
Click to collapse
I have the following:
Code:
StateListDrawable stateList = new StateListDrawable();
stateList.addState(new int[] {
android.R.attr.state_pressed
}, new ColorDrawable(android.R.drawable.btn_default));
stateList.addState(new int[0], new ColorDrawable(Color.YELLOW));
textView.setBackgroundDrawable(stateList);
The background is yellow, but when I press on the textView, the background turns into transparent (it should be like this when i press:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
)
Auroratic said:
I have the following:
Code:
StateListDrawable stateList = new StateListDrawable();
stateList.addState(new int[] {
android.R.attr.state_pressed
}, new ColorDrawable(android.R.drawable.btn_default));
stateList.addState(new int[0], new ColorDrawable(Color.YELLOW));
textView.setBackgroundDrawable(stateList);
The background is yellow, but when I press on the textView, the background turns into transparent (it should be like this when i press:
)
Click to expand...
Click to collapse
well fyi you should look at the view type "states" as not sure you want android.R.attr.state_pressed ... neways you probably want state_focused and state_enabled for an editText view, but really google should provide you with simple absolute answers
hope that clears it up neways
deanwray said:
well fyi you should look at the view type "states" as not sure you want android.R.attr.state_pressed ... neways you probably want state_focused and state_enabled for an editText view, but really google should provide you with simple absolute answers
hope that clears it up neways
Click to expand...
Click to collapse
I have that now:
Code:
StateListDrawable stateList = new StateListDrawable();
stateList.addState(new int[] {
android.R.attr.state_pressed
}, context.getResources().getDrawable(android.R.drawable.list_selector_background));
but when I press on the TextView, the background goes orange
Auroratic said:
I have that now:
Code:
StateListDrawable stateList = new StateListDrawable();
stateList.addState(new int[] {
android.R.attr.state_pressed
}, context.getResources().getDrawable(android.R.drawable.list_selector_background));
but when I press on the TextView, the background goes orange
Click to expand...
Click to collapse
now your setting a state with a state "list" so not sure that will ever work.. needs to be a simple drawable

How to show a map in an activity?

How would I show a map in an activity with a customized marker that shows the current location of the device?
If you're planning to use Google Maps, it's pretty easy: https://google-developers.appspot.com/maps/documentation/android/
And for the device location: http://developer.android.com/training/location/retrieve-current.html
Ianlmt said:
How would I show a map in an activity with a customized marker that shows the current location of the device?
Click to expand...
Click to collapse
Look into using a MapFragment.
Stick one in your layout;
Code:
<fragment
class="com.google.android.gms.maps.MapFragment"
android:id="@+id/myMap"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Then in the onCreate of your activity, get a handle to the fragment and then get the map as a GoogleMap object from there;
Code:
final MapFragment mapFragment = ((MapFragment)getFragmentManager().findFragmentById(R.id.myMap));
final GoogleMap googleMap = mapFragment.getMap();
When you have the GoogleMap instance, it's easy to set positions and markers;
Code:
final LatLng position = new LatLng(100, 100);
map.setMyLocationEnabled(true);
map.moveCamera(CameraUpdateFactory.newLatLngZoomposition, 10));
map.addMarker(new MarkerOptions().title("Some place of interest").position(position));
Hope this helps.
Thank you so much! Going to play with it later today and see what I can produce!
Ianlmt said:
Thank you so much! Going to play with it later today and see what I can produce!
Click to expand...
Click to collapse
Cool, remember that you need to get you API key's sorted to get it to work.
bornander said:
Cool, remember that you need to get you API key's sorted to get it to work.
Click to expand...
Click to collapse
How do I do that (sorry so new to this whole thing)... Do you mean I need to apply for an API key?
Ok I have attached what I worked out in a zipped project file below this post, what it produces is this:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Close, but no actual map is displayed... where did I go wrong?
Thanks for all the help
never-mind it appears I have fixed it ... what I did;
was missing a bunch of code, and the keystone had to match the one that was given to google api, I also had to enable the api from google develper control panel.
Seems to be working now! I am going to keep on tinkering with it, but this is the first map activity I have created... yaaaay

Categories

Resources