Reputation: 5720
I have a problem with this separator:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<padding android:left="10dip" android:right="10dip"/>
<solid android:color="@color/listSeparator"/>
<size android:height="1px" />
</shape>
I'm trying to make a little margin/padding in the left/right of the listview component (using a relative on it , not a ListView Object) . Then when i try to put it this way...
getListView().setDivider(getResources().getDrawable(R.drawable.song_separator));
... it's directly ignored , putting a full layout separator .
Now i don't know what is the problem , but i know that :
Any idea?
MODIFIED
My last partial solution is to put an ImageView , aligned next to the parent bottom . This is partial cause it puts on the bottom but not on the original divider.
If someone can tell me how to put that ImageView on the exact line of the divider, i would give him the +50 too.
Upvotes: 8
Views: 2028
Reputation: 448
Put the header in a separate file and access it as:
public class AuditActivity extends ListActivity {
Budget budget;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.audit);
ListView lv = getListView();
LayoutInflater infalter = getLayoutInflater();
ViewGroup header = (ViewGroup) infalter.inflate(R.layout.header, lv, false);
lv.addHeaderView(header);
budget = new Budget(this);
/*
try {
test = budget.getTransactions();
showEvents(test);
} finally {
}
*/
// switchTabSpecial(); }
Follow this link .......it has a detailed info,use RelativeLayout instead of Linear One, I hope this will help you. Android: Adding static header to the top of a ListActivity
Upvotes: 1
Reputation: 1755
Quiroga so my first bet would be to make the code more debugable by spliting the method call up into individual lines.
ListView lview = getListView();
if (lview != null){
Resources res = getResources();
if (res != null) {
Drawable dable = res.getDrawable(R.drawable.song_separator);
if (dable != null){
lview.setDivider(dable)
}
}
} else {
//Log in some way that you have a problem.
}
I know it looks kind of over complicated but that way you can make sure that the Drawable is found and is the correct one and then properly assigned to the ListView.
Another thing you can try is just assigning a different maybe platform specific separator and see if that works properly.
Also try to get your hands on the Android Source Code it is back online if you add that to your Java Project you can debug into the Platform classes and debug deep into the platform code.
So this isn't really a solution for your problem but maybe it can help you find the solution.
Upvotes: 1