how to create stripes with text view

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

how to create stripes with text view

Postby Umakant » Fri Nov 06, 2009 2:24 pm

hi i am quit new to this technology here i want to arrange the data in rows with alternate stipe but it error so can u help me in ths
private void setupListStripes() {
// Get Drawables for alternating stripes
Drawable[] lineBackgrounds = new Drawable[2];

lineBackgrounds[0] = getResources().getDrawable(R.drawable.even_stripe);
lineBackgrounds[1] = getResources().getDrawable(R.drawable.odd_stripe);
// View
// Make and measure a sample TextView of the sort our adapter will
// return

View vi = getViewInflate().inflate(R.layout.contact_row, null, null);

TextView v = (TextView) vi.findViewById(;
// Make it 100 pixels wide, and let it choose its own height.
v.measure(MeasureSpec.makeMeasureSpec(View.MeasureSpec.EXACTLY, 100),
MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, 0));
int height = v.getMeasuredHeight();
getListView().setStripes(lineBackgrounds, height);

Posts: 5
Joined: Fri Nov 06, 2009 5:31 am


Postby I_Artist » Fri Nov 06, 2009 4:50 pm


I was a little lost with your question but I will give it a shot. The part that really lost me was that last line calling getListView() out of nowhere...


The gist of your question is that you want to create a stripped background. May I suggest you create one image containing both your 'odd' and 'even' stripes, then just repeat it? Take a look at this post.

I hope that helps,

The I_Artist

follow me on Twitter: @I_Artist
follow Android Development on Twitter: #androiddev

Show the world that you are an #androiddev, wear the badge
User avatar
Posts: 33
Joined: Fri Oct 16, 2009 3:49 am
Location: St-Eustache, Quebec


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests