While working over listView I have came across a trouble situation.
Actually I am having a image view defined in layout that is to be inflated,
And I am doing so by adapter with my own bean class XYZ.
Now what I want is I'm checking the variable pic of the bean.
If no image there ,the image view is to be hidden or gone,
When the "pic" is available it should show the list,
But the ListView getView is called everytime I scroll,,, The image appear and disappear abruptly on list scroll,
Please help me put of the situation.
I want ImageView to be displayed when it is available. And hide it when pic tag is " " (empty)
You should create a transparent image and put it in dise the drawable folder
add a condition in side the getView method
if (tag==----)
ImageView.setImageDrawable(R.Id.TransparentImage)
else
ImageView.setImageDrawable(R.Id.AvailablkeImage)
it is appear like as image is hidden in list view.
I hope this is help.
Related
The question might be duplicate ..sorry for that.
I have an activity (test activity) and array adapter (test array) for same.
The list contains image and text. but the image is not displayed always. It has some condition. So look is like
---------------------------------------
image1 text1
test2
test3
image4 test4
---------------------------------------
So test activity display the above list on screen.
Now i want to do different screen load on image (image activity) and text (text activity).
As the on-click handler will be in separate file (test array) i am not sure how to return to test activity and to specific task.
actually i have a list view with image and text.
Below are some scenario
Image will not be present on each row.
If image is present then Onclick of image shown other screen (for example image activity).
if user click other than image that is text show text activity screen).
What i have done is i have a list click handler in a separate file that is ArrayAdapter so i cant't do image click listener there.
So the issue was how to identify which row image is clicked?
Solution:
After lots of R&D and code changes i done below and its working:
I have added android:onClick="ImageClickHandler" for image click in xml.
and during row creation i have set row position as Id.
So when clicked on image you can get position by view.getId(), so u have the position when u click on image and hence you can get complete data on that row.
Might be there is another way....but this is what work for me.
i have new's feed ListView and each item content text and images , the images has been drawled by ImageGetter() from remote server
so my question is what is the simplest way to make those images clickable ? like if user want to view picture in large mode , aim still newer for android drawable where to start ?
The View that has the image just needs a click listener attached to it. When the View with the image is clicked, handle it by either bringing up a new activity with the image as he background (larger version), bring up a Dialog with the image, or add a View from the WindowManager.
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
Actually I am able to use empty listview in my application when I am having Single list.But I am encountering with two different list which is using same xml.Now how should I proceed in order to get 2 different images to my different list when they are Empty,
If you are using imageview with id android.R.id.empty.
then simply use this
ImageView image=(ImageView)findviewbyid(android.R.id.empty);
and set the desired image.
Yep Akki that was almost correct with a little changes in my XMl.The Final code is here
All I had to use the same textview described inside the list xml file.
TextView tv=(TextView)findViewById(android.R.id.empty);
tv.setBackgroundResource(R.drawable.anniversary_reminder);
Set the visibility of whatever image you want to VIEW.GONE when your list is not empty. You can then create two different images in your layout. Have them initially set to visible.
In the onCreate method check the ArrayList you are using for your adapter when loading the list to see if it is empty. If it is not empty then set the visibility of your image to VIEW.GONE. Then all you have to do is do this same check whenever there are deletions to the list. (because you can't get an empty list by adding more entries) And whenever you make an addition to the list set the visibility of the image to VIEW.VISIBLE. (so basically wherever you do a notify of a data change on the adapter)
Hopefully this logic helps out!
ImageView emptyListImage1 = (ImageView) findViewById(R.layout.image1);
ImageView emptyListImage2 = (ImageView) findViewById(R.layout.image2);
emptyListImage1.setVisibility(VIEW.GONE);
emptyListImage1.setVisibility(VIEW.VISIBLE);
I am using customadapter to set data for list which contains a text view, imageview and a layout with some buttons. the buttons layout will be invisible initially. When we click on list item the layout has to appear with user able to click a button. This work fine as long as ImageView is static.
But our build will fetch image from url and set it to view. Here the refresh issue arises. The Layout is unable to be view.
List refreshes when re apply any external even such as Track ball or scroll.
Please help me regarding this.....
Without actual code, it's hard to tell what the problem is, but have you tried calling invalidate() (inside UI thread) or postInvalidate() (outside UI thread) on the layout or any view you need to redraw? This forces the view to call onDraw() again.