I am working on Grid View, where I am in a need to click and select an image by showing a small image over it. As you can see in the image attached, the green mark over the images shows they are selected. This is not possible with Normal Grid view. I have tried this.
Please suggest me.
Guys from google have already done everything for you to solve your problem
so, you got to use ActionMode in your Activity and fill up your gridView.
http://developer.android.com/guide/topics/ui/menus.html#context-menu
so when you entering ActionMode just set your gridView object in ChoiceMode-> Multiple.
in your code:
GridView gv=new GridView(this) or this.findViewById(R.id.ma_grid_view);
GridAdapter adapter...
gv.setAdapter(adapter)
beginActionMode(); // this might be used by a long press or by button tam in action bar...
public void beginActionMode(){
gv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
kinda like this, read the article i'v send you
spend some houres and you'll reach it...
thanks.
for that you have to create custom adapter and make layout for your grid item,in layout use relative layout or framelayout.
using these you can overlap your images
here are some link for your help
custom adapter
cusotm adapter
custom adapter for gridview in android
Related
I want to create android app about an article that contains 30 chapters so i am to make 30 buttons every button will contain different text stories so please tell me how can i show these 30 buttons in list view instead of showing in normal linear layout of vertical orientation please help me out?
Here is simple tutorial containing listview with Button. On click of button, based on position, you can show content:
Listview Tutorial
You can use Custom listview / recycler view Please take look into this.
I'd like to show a menu when I click in a view (Linear/RelativeLayout) like the images below
Anybody knows how to do it?
Thanks!
The UI-Element you're looking for is called a Spinner (Docs). As far as I know the default implementation of the Spinner/Dropdown-List displays only text without any kind of drawable (circle) like in your screenshot.
So what you have to do is to create you own layout and Adapter for the Spinner.
The view you are looking for is called Spinner. Android has excellent documentation about this subject.
If you want the spinner to go up, like in your picture, you will have to place it at the bottom of your view, since it will only go up if there is no room below
You should use the Spinner view
If you would like to customize the view elements, than you should change the default ArrayAdapter to yours and override the getView() method.
I wanted to add a listview in an image button in such a way that when i clicked the button the information which is present in the listview should display in the next page. Could anyone help me with this??
see this is how it should be if i click on any of these buttons it has to list the information and that to be displayed in the next activity not in the same
You cannot add view to another view. You can to viewGroup, but not to view. So i would suggest you to take a screenshot of your listview (which you will have to create it first, or you should figure something else out) and then set that image into imageButton.
you can use tabhost to create tabs with the images. Plz take a look at the following tutorials:
Tutorial 1
Tutorial 2
Tutorial 3
Inside each tab you can place the custom list view.
I really need horizontal scrolling in my app, so I overrode Gallery and I'm trying to do something with an OnItemSelectedListener, and a GestureDetector I'm calling from an OnTouchListener I've set on the Gallery. What I want is to remove the auto-selection of Gallery items as I scroll, but I want to be able to click an item to select it.
If I set an OnClick listener on a view that is populated in the adapter, the Gallery fails to scroll. Also, the OnItemClicked event is never called for the listener I set for that on the Gallery.
To remove selection from all items you should do this:
youGallery.setUnselectedAlpha(1);
Maybe my answer to this question will help you. It's something which wasn't intended to be ever realized...
For your case why dont you just use a HorizontalScrollView. Just put a linear layout inside and add as many imageview's as you need if your using images, or dynamicaly add it in java code.
This will elemenate the selection of gallery by default. This will be easier than trying to Override the Gallery widget default methods.
Why not you set some tag while you click on an item in the Gallery to select.
Now once again when you click after the item is selected just check for the tag that you had set, and based on the condition you can move to new screen and whatever task you want to perform.
But keep one thing in mind, you have to set the tag with every gallery item while building the gallery view.
I hope you will get what I want to say.
If still you have any problem then let me know.
I had the same scenario and I solved that.
I have a list view which has a couple of views within it, I have a textView and an ImageView.
What I need to do is, I want a person to be able to click just on the imageView without causing the onItemClicked function to be invoked, If the person clicks the ImageView, it should do something else, but if the person clicks away(apart from the imageview) from the imageView, then the onItemClicked is fired.
How do I do this?
It is kinda like, the listView on the android phone callLogs whereby, the green phone icon is somehow separated from the list but when clicked, it should know which listItem was selected and act accordingly.
I will appreciate the help. Thanks.
Here are some links for you are looking for. Advanced but if you stick with it and dont give up on this, you will learn a ton!!! Take a look:
Android: ListView elements with multiple clickable buttons
Android custom list item with nested widgets
use holder.imageView.setOnClickListener() in getView() method of adapter class.