How to set group indicator for ExpandableList View dynamically ?
I had group_indicator.xml in drawable folder.
But no idea of how to set it. Can anyone help please...
First set android:groupIndicator="#android:color/transparent" to your expandable list view in xml. Then you can set any indicator that you want to set. Suppose you have an image named "pin" in your drawable folder, then you need write following lines.
ExpandableListView explist;
Drawable d = getResources().getDrawable(R.drawable.pin);
explist.setGroupIndicator(d);
Thanks...
Suppose you have created ExpandableListView through code:
ExpandableListView ev = new ExpandableListView(this);
ev.setGroupIndicator(getResources().getDrawable(R.drawable.group_indicator));
Related
I have a GridView and I need to add a footer view to. I know this is possible to be do with a ListView using code like this:
LinearLayout layoutFooter = (LinearLayout) getLayoutInflater().inflate(R.layout.footerview, null);
final ListView listView = getListView();
listView.addFooterView(layoutFooter);
But how do I do the same with GridViews? This approach doesn't seem to be working for GridView. Any idea? Cheers.
use relative layout as a parent layout and set your footer ,center and header postion and put your grid view in center position and desired footerview at footer position.
Here's a good soluction to do this.
I want to set the opacity of each and every Listview row using android:alpha. I tried doing so but the row doesn't get the transparent background. I have a colorful background of the layout and I want a glass or transparent type of row of the ListView. How can I do it?. I don;t want to use any adapters for this. So please suggest some simple methods.
View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);
If you are set opacity of listView us below Code
android:background="#80ColorCode"
I'm developing an android app with fragments. While most of my layouts are pre-determined in the XML, I would like to programmatically insert a new view between views that were already loaded in a LinearLayout at startup.
How do I go about with this?
Thanks
Its possible to specify index while u dynamically add a view to a LinearLayout.
Set height of the first view as
android:layout_height="0dp"
android:layout_weight="1"
Set height = wrap_content for the second view in XML
Then while u are adding new View dynamically, set its height = wrap_content and add it to the parent LinearLayout like this
parentLinearLayout.addView(childView, index);
//index = position where you want to insert the new view.
It might help you. :)
the red View should have the default setting View.setVisibility(View.GONE) right at the beginning. When its time to show up you can switch over to View.setVisibility(View.VISIBLE). I cant verify the solution right now, but it should do the trick. So in this case you are not inserting a new View but make an existing one visible.
I'm using a ListActivity with an ArrayAdapter. I have an array of Strings, and I want to put a divider after the 5th String in the list. Is there any way to do this? Sorry if there are duplicates, just did not find what I was looking for. Thanks in advance.
There is a hack.
Add a divider view at last in your list_item's layout file and give it an Id. Now in your custom adapter class,you can set that view's visibility depending on the position whether you want it to be shown or not,in getView() method.
A property of Listview will help you:
android:divider = (color or drawable)
And also
android:dividerHeight = (integer in dp)
I have an expandable list view I am using in one xml file which has a background. Upon loading, it looks fine, but sometimes while browsing the background of each list element shows infront of the background of the base view.
The list elements are defined in their own xml file.
Can I make the list elements backgrounds become transparent somehow, so that the background of the baseview is shown all the time instead, even when expanding/collapsing the view?
The answer can be found here :)
http://developer.android.com/resources/articles/listview-backgrounds.html
Use
android:cacheColorHint="#00000000"
On your list
Set this all four properties for expandablelistview. It worked for me....
android:childDivider="#android:color/transparent"
android:listSelector="#android:color/transparent"
android:cacheColorHint="#android:color/transparent"
android:background="#android:color/transparent"
Or programmatically set expandablelistview transperent:
ExpListview SecondLevelexplv = new ExpListview(mContext);
SecondLevelexplv.setBackgroundColor(Color.TRANSPARENT);
SecondLevelexplv.setCacheColorHint(Color.TRANSPARENT);
SecondLevelexplv.setDivider(new ColorDrawable(Color.TRANSPARENT));
SecondLevelexplv.setSelector(android.R.color.transparent);