I am a beginner in android studio.
In an application there are five horizontal rows. In any row there are ten pics and properties of the pic. Click on any pic put extra to intent and direct to another activity.
How can I write onclick event for all pics?
Should I write 50 onclick events for all pics?
Is there any other way?
Thanks
You can use GridView for the layout you are displaying. Refer Doc here.
And example here.
Add to the ImageViews: "android:onClick="navigateToNextActitivy"
and declare the navigateToNextActitivy-Method in your Activity and put your code to navigate here.
or put a container arround your pics and add the "android:onClick="navigateToNextActitivy" there
In this case you can use a GridView. Here is an example answer where you can find how to do it:
Simple Android grid example using RecyclerView with GridLayoutManager
Related
Hello guys just wanna ask about creating like the image below .. i
search all about it here but fail to see similar on my question .i
know i would use layout_weight but cant do what i want it to be
like.see attachment below .. i wanted to do atleast 3 buttons .any
help please ?
https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/149364_1489250518001074_8490520321510060718_n.jpg?oh=647bbe485caabf52ad8de32e5e7412ac&oe=54B27214&__gda__=1424652329_8648e09f0cbd8b85c95ec64ebf14d1b9
I think you can do this pretty easily using a Gridview layout. You would create a gridview with a column number of 3 and just add 6 items to the gridview. You will also have to override the getView method of the adapter for the Gridview and return a imageview that contains the image you want to display.
Follow this guide for more instruction about using layouts, then try and follow the instructions I laid out above.
http://www.mkyong.com/android/android-gridview-example/
I was wondering how to implement the listview like the android market.
in the right hand panel a listview is divided into the two rows. This is very useful because it saves lot of space and user can look at almost double items in the listview at a time. how can I implement this ? any suggestions?
you can use GridView instead of ListView of two columns..
1. GridView
2. GridViewExample
Sample design :
The Android Market also uses the ViewPager to scroll between the pages. Here is an example on how you could implement it.
There is another question that is related to this one.Check the folling link, it might help you:
How to display a two column ListView in Android?
Modify you *.xml file to get what you want.
Good luck!
If you want to do this using listView, then each item (row) in the list view should consist of two views. You can do this using a relative layout (or linear layout) with two items side by side.
You can also implement this using a gridview having two columns.
I want to create a horizontal listview which contain many item, one item will contain a image. When user slide listview => the count of item will be fix when it display, example display only 3 or 4 image. How can I do that? Many thanks.
Edit:
I use this
to create a HorizontalList view, everything is ok but I don;t know how to make the Next and Previous button work! Any idea?
Instead of a horizontal ListView (which, as far as I know, isn't offered by the Android SDK) you can use a HorizontalScrollView. You can add the items like to any other kind of layout class.
It looks like what you are looking for is a Paginated Gallery. I have written one here.
Its still only a couple of days old but hopefully the included Activity code will get you off the ground.
could someone help me how to add this selected line which you can see on picture to ListView (I mean lines as "General, Incoming calls, etc."). I have made ListView using a HashMap, but I don't know how to add this line to my ListView. I'll be very thankful if anybody help me.
Picture here: http://img11.imageshack.us/img11/1795/sc20111010202936.jpg
Can easily be done with preferences and is called a preference category here is a good tutorial on preferences
http://www.kaloer.com/android-preferences
The Desired List View can be achieved in two ways:
1.Creating a Section List View Click here for Help
2.You can use the text with that background image in your xml for infalter layout.
And make it visible and invisible accordingly of your categorization.
Hope this would help you and guide to right path
Hey all,
I know that this question has been asked many times in this forum itself. But I am not able to get a working solution out of any one of them.
My problem is that I need to create a list view with images. The content is static. Eg: Lets say i need to display 5 rows of data and I have 5 images to go with these rows. All i need to do is to display them in a list format!
Simple right??
Thanks in advance!
Hey nice to see somebody facing the same problem as I did.
Here is the very simple solution for that.
Make a ArrayList add your five elements in that named COUNTRIES.
create one list_item.xml file with one ImageView named imageview and one TextView named textview in a linear layout(This layout will repeat for your each row in ListView).
Dont forget to set image in ImageView to any defult icon or something.
in your class that extends ListActivity simply enter following line and you are done.
setListAdapter(new ArrayAdapter<String>(getApplicationContext(),R.layout.list_item,R.id.textview,COUNTRIES));
In case you stuck anywhere you can ask.
You need to write a custom layout for the rows and pass it to the Adapter that defines the content of the list (you most probably want to write your own, but there may be some predefined ones).
See e.g. this TweetAdapter
that uses this layout
The left screenshot shows how this looks like.