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(android.R.id.);
v.setText("X");
// 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);

}
Umakant
Freshman
Freshman
 
Posts: 5
Joined: Fri Nov 06, 2009 5:31 am

Top

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

Hi,

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...

Anywho.

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,

Cheers!
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 http://www.twibbon.com/join/androiddev
User avatar
I_Artist
Developer
Developer
 
Posts: 33
Joined: Fri Oct 16, 2009 3:49 am
Location: St-Eustache, Quebec

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests