Android : Iterate Through All Views In View Group Without Knowing Their Ids?
Feb 12, 2009
I'm looking for a way to iterate a viewgroup to retrieve all child views without calling findViewById(). Does view count and view position line up? So can I get the view count and then use that as a counter to call getChildAt(int index)?
View 2 Replies
Feb 11, 2009
I'm looking for a simple method to search a ViewGroup for a specific view given the id. This ViewGroup could have nested ViewGroups as well, so it needs to be recursive. Anyone know if Android as some type of view iterator? I can't seem to find anything.
View 4 Replies
View Related
Jan 6, 2010
I have a simple ListView and on that ListView I have placed a number of custom defined Views. The CustomView has ImageView and two TextViews.
The CustomView also has a "stateful drawable" as background, so that the background image (a 9-patch) changes if you press the Row in the ListView. When pressing the Row, the background image changes to a Red-ish thing.
The problem is that when the background changes from the default greyish, all the Views in the CustomView (ImageView and TextViews) still have their greyish background and thus creates very ugly greay boxes on top of the now redish background.
What is the best way to solve that problem? I hoped that such things were handled automatically (as it is done in for example .NET), but I was wrong it seems.
View 1 Replies
View Related
Jan 2, 2010
How do I use the ResourceCursorTreeAdapter with the following constructor?
ResourceCursorTreeAdapter(Context context, Cursor cursor, int collapsedGroupLayout, int expandedGroupLayout, int childLayout)
I'm trying to use a it as follows. code...
View 2 Replies
View Related
Sep 20, 2010
i've got an ExpandableListView with my own layouts for the group and child views. a certain group-type will require a different layout. is that possible - i.e. a ELV with different layouts for a group view. i've got my own sub-class of SimpleExpandableListAdapter.
View 6 Replies
View Related
Aug 15, 2010
I am working on an Android project where a group of buttons needs to show on the bottom of every screen (activity) in the application. The group of buttons are basically a navigation bar. I want to know the best way to do this without creating new buttons for every activity. I have been around programming (C++/C#) for many years but am pretty new to Android and Java so if someone can point me in a general direction.
View 2 Replies
View Related
Feb 11, 2010
I have a ViewGroup and it has a few children. And one of them is a TextView ("+id/text"). In my code, I would like to know how can I add a new View or ViewGroup which will be positioned vertically aligned and below the TextView (+"id/text")?I have followed the advice below and try to use TableLayout. As a test, I try to layout statically to make sure things are aligned correctly. Here is my layout xml:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/panel" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">..........
View 2 Replies
View Related
Jan 27, 2009
Just use findViewById(R.id.layout_2)
View 5 Replies
View Related
Feb 9, 2010
I'm still trying to figure out how best to layer views on top of other views. I want to do something like the ZoomButtons on top of a custom view. I tried getting the ZoomButtonsController's parent and then adding views, but I didn't have enough control and they ended up on top of the buttons. I've gotten close by using a FrameLayout and some gravity on the top two views. But this has some interesting effects. Since this is contained with a tab, these two top views appear on top of all four of the tab pages. I want them on top of one of those pages only. Apparently, nested FrameLayouts don't mix well. What is the proper and expected way to do this? Here is more or less my complete layout....................
View 4 Replies
View Related
Oct 9, 2010
Is there a possibility to add a view or derivative (button, textview, imageview etc...) to another view without having to go through layouts?
I have a class called ScreenView, it derives from View (e.g. public class ScreenView extends View).
I wanted to display text into it, labels, images etc..
On an iPhone it's trivial, simply create my objects and use addSubview method ; you can embed any UI objects into another. Most UI toolkits work that way too.
Problem with layouts is that I haven't found an easy way to properly position a subview (say a text view) in a given location of the enclosing View. I want one to contain the other...
I was hoping I had missed something in the documentation (which is far from being intuitive that's for sure) and I could do something like myView.addView(subview). But it ain't so :)
As a side question, what is the closest to iPhone's UILabel in the Android world?
A UILabel can contain a text or a graphic. Right now I've been using TextView and ImageView but they aren't anywhere as flexible when it comes to layout as a UILabel
Edit: Making my View inherit from ViewGoup instead, let me add subview..
However, I want to draw in my view. I found that when ScreenView extends ViewGroup, the onDraw function is never called then.
Something like:
CODE:..........
Would paint in yellow my view if ScreenView extends View ; but not if it extends ViewGroup.
How do you draw directly in the view then?
View 2 Replies
View Related
Jul 26, 2010
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/llAddNote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="8dip"
android:background="#CCFFCC">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="24dip"
android:text="Add Notes"/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dip"
android:layout_marginRight="24dip"
android:id="@+id/tlNotes"
android:stretchColumns="0">
</TableLayout>
<Button
android:id="@+id/bAddNoteLine"
android:layout_marginLeft="24dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ADD">
</Button>
<LinearLayout
android:id="@+id/llIndex"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="21dip"
android:gravity="center">
<Button
android:id="@+id/bSaveSubjectiveNote"
android:layout_width="192dip"
android:layout_height="wrap_content"
android:text="Save"/>
<Button
android:id="@+id/bDiscardSubjectiveNote"
android:layout_width="192dip"
android:layout_height="wrap_content"
android:layout_marginLeft="48dip"
android:background="@drawable/button"
android:text="Discard"/></LinearLayout>
</LinearLayout>
How to retrieve the index of linearLayout which has "llIndex" as id.
View 1 Replies
View Related
Mar 25, 2010
The reason for me to do this, I have created these 2 views in the beginning of the app. SO they are always present. But in some cases where i want only 1 view(which is surfaceview) and if i dont need the 2nd view(i.e, videoview), i am still getting a black patch at the palce where i have defned a videoview. want to get rid of this. Can anyone please tell me if it is possible to disable views/surfaces corresponding to them? If so how can we do this?
View 2 Replies
View Related
Oct 23, 2010
I am trying to figure out how to add a child view to a parent view so I can use the MotionEvent.ACTION_MOVE feature to move from one child view to the next. Is this possible?
View 4 Replies
View Related
Nov 11, 2010
I have an List Activity with a Base Adapter where the contents have changed (example - the rows are reordered). I have tried invalidate.
Code...
View 6 Replies
View Related
Apr 19, 2009
Is it possible to add a view dynamically that overlaps other views in the layout. I have Linear Layout defined for the activity. As part of the Layout I have a custom View. The content changes dynamically and sizes appropriately based on the content size, with fill_parent for width and wrap_content for height. But what I want is, dynamically take over the full screen and then based on a click go back to the normal mode. Is there a mode to display a view where - in it can overlap all other views in the layout?
View 3 Replies
View Related
May 14, 2009
Is it possible to clone a view. If no, how to support clone of a view in custom views. If yes.. which api should we use. clone method seems to be protected for view.
View 2 Replies
View Related
Mar 11, 2010
I am developing a small app for Android. I am creating my own view.
I am planning to design the layout to be:
<LinearLayout>
<MyView>
<Button><Button>
</LinearLayout>
But when I run my program, my custom view will cover the whole screen. Is there anyway to avoid this?
I have already tried to add android:layout_width, layout_height to be wrap_content, fill_partent, but no luck.
View 3 Replies
View Related
Oct 13, 2010
I've got a schedule Class, which is simply a custom ViewGroup (with custom onMeasure() and onLayout()), which enables me to place childs(=events) with LayoutParams for column/row start and column/row end. The number of childs and their LayoutParams depend on database entries.
Now I'm trying to add childs (events) from my database. I'd have to use a Cursor Adapter, so my schedule Class has to extend ListView, right? I tried that but the newView() method of the adapter is never called. Why not? My custom ListView doesn't ask the adapter for childs, no childs are added. I also can't add the childs by hand calling schedule.addView() if I extend from AdapterView.
How can I add events to the schedule with the data from the cursor?
View 1 Replies
View Related
Jun 10, 2009
I'm trying to implement an expandable list view where the group view contains a label and a checkbox, visually represented below (the v and > are the expand/collapse icons, the [x]/[ ] a checked/unchecked.
View 2 Replies
View Related
Oct 18, 2010
I was wondering if there is a way for placing a view to the right side of another view and centering it vertically on the second views height. In know this can be done using a LinearLayout, but for other reasons the 2 views must be part of the same RelativeLayout.
View 1 Replies
View Related
Aug 1, 2012
I worked as android developer, any sample code for carousel view for group of immages which should display the image and its name in the text view?
View 1 Replies
View Related
Aug 11, 2010
I want the view group to extend with the ScrollView if the content of the group is smaller than the display area of the ScrollView.
How can I have the ScrollView child extend to fill the parent if it's smaller than the parent?
CODE:.........................
View 3 Replies
View Related
Oct 6, 2010
I have a layout xml file with a linear layout. One of the children is again a ViewGroup Relative layout. In my java code i want to change the width of this child Viewgroup for my requirements. I tried this
ViewGroup childViewGroup = (LinearLayout)findViewById(childViewGroup);
LayoutParams l = childViewGroup.getLayoutParams();
l.width = 360;
childViewGroup .setLayoutParams(l);
I couldn't do this because findViewById(childViewGroup) doesn't fetch ViewGroups it does only for Views. Note: I cant define a whole new layout.xml for this minor requirement since it is huge layout file and might cause performance overhead. I wanted to just change the width of the child view group in my java activity code.
View 1 Replies
View Related
Feb 12, 2009
I am trying to iterate through all the photo images (produced by ADP1 camera), held on external SD storage in an ADP1. I want to extract the binary data for each image file, determine image size in bytes and send the image data (possibly after compression) over a network conection.
My code is generating an exception when I try to generate a Bitmap based on Photos taken by the ADP1 Camera, stored physically on External SD Card Storage. It looks like the image size is exhausting VM for my application.
I attempt to extract a Bitmap via android.provider.MediaStore.Images.Media.getBitmap() static member function. Code...
View 2 Replies
View Related
Mar 18, 2009
I have table with 3 columns which is binded to an XML document with three text views.
CODE:........
Depending on the value store in the third column, I want to change the text color in R.id.c. How should, I go about with this.
This is what I have so far :
COD:...............
View 3 Replies
View Related
Nov 16, 2010
I am implementing a music player application in Android. My play list selection screen is implemented as a tab selector widget which contains a ListActivity inside each of the tabs: Artist, Albums, Songs.
I want to update the ListView in each of the ListActivity when I delete an item from any of the lists.
i.e. When I long press an item in the Artists list a context menu is drawn with "Delete Artist"
And it should delete all the songs from this artist in the Songs ListView, delete all the albums by this artist in the Albums ListView, and finally delete the entry for the artist in the Artist ListView.
Each of the ListActivity has its own fillData() method, which updates the ListView when the button in the context menu is pressed.
How can I call the fillData() method of the Albums ListActivity after I update the ListView inside of the Artists ListActivity?
View 1 Replies
View Related
Feb 28, 2010
I want to populate a table, defined in layout xml file through the programmatic way. I have define Table with a single row defining its header, with all the attributes set. Now i want to know a way so that i can just replicate that header row in the table with new content.
I tried using inflator inflate(int,view) method, but at runtime it showed up with error.
Here is the XML code for the layout file defining the table
CODE:.................
View 1 Replies
View Related
Jan 17, 2010
Simple question, what is the fastest way to iterate through collections on Android? I generally use collection.iterator(); and the iterator.next() to iterate through the whole collection. Is it any faster to drop that and iterate with "old" (and I use the term old loosely) for( int i=0; i<collection.size(); i++) ? I was thinking of getting the collection.size() into a separate variable so I wouldn't be asking the collection it's size all the time so basically the for loop would turn into something like this: int size = collection.size(); for( int i=0; i<size; i++ ) collection.get(i); Any better? Speed wise, I mean. I'm in a point where I need to get every possible inch of speed for my application. Or maybe allocate everything into Lists in the start, and once I know the correct amount of data, I turn all that into arrays and drop the Lists so I can have array[index] (Log(1) access, right? OH wait. how did this go again access instead of having the "slow" method calls in between like .get(); when accessing the data in the collection.
And what about getters & setters for Classes? Like let's have a Vector2D class that contains obvious integer x and integer y values. What is the fastest way to access them inside the class? Have them as public and just straight Vector2D.x = someValue; or through getters and setters? I've had much debate with my tutor about this (working on my final year project) but not to get too much into details of it. Also all links for further Android application optimisation are more than welcome and greatly appreciated (I read the googles docs on this already). Plus if you have found some really good tricks / quirks on Android to punish the device even more so it runs faster, do share, do share. Please be gentle on me, I'm such a beginner in all things Android that I feel absolutely dumb as a boot for asking these kind of things. I come from strong C++ / Java background but getting the extra inch of speed for everything on Android is so different than optimizing code for PC side and not that you even have to do it on PC side that often.
View 3 Replies
View Related
Dec 23, 2009
What's the functional difference between these list view methods: invalidate() and invalidate Views() ? Which one is faster to refresh a list view?
View 3 Replies
View Related
Mar 6, 2010
I have the following XML code:.................
The idea is to change the views, whenever I press one of the radio buttons. When I press a button the first time everything works out fine, but the second time I press a button, I get an IllegalStateException, and I can't quite see why I'm getting this.
Also, the Activity seems to set all my global variables to null, which is why I have to create them every time I switch from portrait to landscape or vice versa. So I would like to know if there is a way I can save my views in the Bundle, or any other way in which I can permanently save my views, so I don't have to add or create them every time, I flip the phone. And whenever I flip the phone, it seems that it rereads the main XML file, causing the RadioGroup to be set to 2D even if the 3D button is checked. This is because I've said the 2D button to be checked from when the app is first created, but I would like to also save the state of that RadioGroup.
View 5 Replies
View Related