Curved border for list view

HI,

I am newbie to android and java, i need to create a simple application in android. I have a Activity page in this activity. Here is my activity page

package com.tkcmu.dev;
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList;
import org.apache.http.client.ClientProtocolException; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject;
import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView;
public class tkcmu extends Activity { private ListView lv1;

@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); ArrayList<String> listItems = new ArrayList<String>(); try { URL recentUrl = new URL( "To some link"); URLConnection tc = recentUrl.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(tc.getInputStream())); String line; while ((line = in.readLine()) != null) { JSONArray ja = new JSONArray(line); for (int i = 0; i < ja.length(); i++) { JSONObject jo = (JSONObject) ja.get(i); listItems.add(jo.getString("content")); } } }catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } lv1=(ListView)findViewById(R.id.ListView01); // By using setAdpater method in listview we an add string array in list. lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , listItems)); }

}

and my main.xml is like this

<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"> <ListView android:id="@+id/ListView01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/customshape" android:layout_marginTop="10sp" android:layout_marginLeft="10sp" android:layout_marginRight="10sp" android:drawSelectorOnTop="false" android:cacheColorHint="#FFFFFF" android:clipToPadding="true" android:focusable="true" android:focusableInTouchMode="true" android:clickable="true" android:longClickable="true" android:footerDividersEnabled="true" android:headerDividersEnabled="true" android:dividerHeight="1px" /> </LinearLayout>

and also i have an customshape.xml in drawable which is

<shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="10dp" /> </shape>

and i got the result with the entire custom list section get curved but i want to get each row with a curved background. I have posted my entire code here(exclude android manifesto.xml) so this will be appreaceated if any body tell me exactly what changes i need to in this code. Any body have an idea about how to implement it.

Thanks in advance

-------------Problems Reply------------

I never done this for rounded corners, but I would try to provide a custom adapter for the list. A custom adapter would allow you to specify which view to use for each item. In your case, you could try to provide a view with a rounded corner borders (defined with a shape XML).

To do this, you would replace the line lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , listItems));

with a BaseAdapter that implements the getView() method.

There are literally hundreds of tutorials on how to do this, but this one seems to be more detailed.

Category:android Views:0 Time:2011-05-03
Tags: android

Related post

  • CSS curve border in IE not working 2011-05-31

    Curve border is working on Firefox ,Google Chrome but not working on IE?any idea how to do make it work ? -moz-border-radius-bottomleft:2px; -moz-border-radius-bottomright:92px; -moz-border-radius-topleft:92px; -moz-border-radius-topright:2px; -webki

  • way to generate a curved border around the table? 2011-10-11

    What is the best way to create a curved border around the table? Using border-radius property simply puts a curved border around the outer part of the table. However, the individual cells generate a dual border. <table class="round" with="100%" he

  • CSS - SELECT Element - BORDER-RADIUS - Opera showing border behind select input? As in no curved border? 2012-01-27

    I am having trouble trying to style a select element in opera. What happens, is that most of the styles applied to this element in the css is shown in Opera (11.60), but for some reason bits also get left out, like the box shadow effect and border ra

  • Bottom border for list view in android 2010-10-21

    I'm trying to add a bottom border my listview in android The code i used is <ListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:scrollbars="horizontal" andr

  • How to give Border to list-view in android 2012-04-15

    I am developing an application in android java Eclipse having two list view side by side and I want to add border to each list-view. How can do it? Please help me... --------------Solutions------------- once try this to have seperator between two lis

  • how to remove non-printing margin border in layout view 2013-07-23

    How do you get rid of a non-printing page border in the print layout view of Word 2010. It is distracting to see this on the page. --------------Solutions------------- What you describe could be text boundaries. Click the Office button, and then clic

  • HTML Div element have curved border 2014-02-06

    I want to have the bottom curved in my Header Div. Basically the div should be slanted, i tried the below, and its working in all latest browser's except ie8 & below <div class="HeaderTitle" style="background: #000;"> <h1 class="header"

  • curved border in css 2011-02-02

    I want to make design css like this ---------------------U-----| I couldn't draw exact design here. but the U shape width should be expanded to fit home about links. is it possible? --------------Solutions------------- It's hard to decipher exactly w

  • Is there an easy way to add a border to the top and bottom of an Android View? 2009-10-21

    I have a TextView and I'd like to add a black border along its top and bottom borders. I tried adding android:drawableTop and android:drawableBottom to the TextView, but that only caused the entire view to become black. <TextView android:backgroun

  • SSRS: Report border should not been displayed in Report Viewer 2011-09-06

    I have a report created in SSRS 2008 that I call from and display in an asp page using the Report Viewer Control. In the Report Viewer my report has border surrounding the charts, i would like to disable this border completely and make it only the ch

  • Dynamically changing the border of View 2012-04-26

    I am just planning to implement a view whose border color keeps on changing dynamically at run time based on a timer. For example initially the view's border will be in green color(timer=20sec) and every sec the green color disappears and once it goe

  • IE9 border-radius shorthand not supported? 2011-03-16

    I have a few things I've made in the past that have the border-radius attribute like this: border-radius: 7px; This is not working in IE9. I thought IE9 was supposed to support border-radius? If you need an example, see this site. All of the boxes on

  • How to curve a Mapview and shadow it's borders in iPhone? 2012-03-26

    i have tried curving a UIView,UIImage view and also set shadows and corner/border radius to them as well.My doubt is is the same possible with mapview,can we curve a mapview? i used a curved view and inserted a mapview in it but that resulted as an e

  • why is firefox missing the border on some html tables 2010-01-14

    i am using 3.5.7 version of firefox and i have the same css used in multiple html tables but there are some examples where parts of the borders are not shown. What makes no sense to me is that the same css on the same page for another html table work

  • Does Quartz for iPhone draw non visible portions of a view? 2010-02-08

    I am wondering which is the best way, in terms of speed and efficiency, to draw a frame around an image on iPhone, especially when I have to draw lots of these images: 1) Drawing the image and then the frame around or 2) Drawing a rect, filling it wi

  • How do I add text to curved image? 2010-05-18

    $config['source_image'] = '/path/to/image/mypic.jpg'; $config['wm_text'] = 'Copyright 2006 - John Doe'; $config['wm_type'] = 'text'; $config['wm_font_path'] = './system/fonts/texb.ttf'; $config['wm_font_size'] = '16'; $config['wm_font_color'] = 'ffff

  • Using border-radius on ul with only giving a radius to the outer li's 2010-05-24

    Maybe the answer is really simple. But what I'm trying to do it to make a curved border around the li's. So not only the outside but also the inside: Examples: Right Wrong: Don't mind the differences. What I'm trying to do it to curve the inner borde

  • why doesn't the cursor show up for resizing docked views? 2010-06-18

    A strange thing started to happen with our application. The mouse cursor used to change when you hover over the border of a view so that you know you can start to drag and resize that view. Suddenly the cursor no longer shows up and it's difficult to

  • Cocoa Touch: How To Change UIView's Border Color And Thickness? 2010-07-25

    I saw in the inspector that I can change the background color, but I'd like to also change the border color and thickness, is this possible? Thanks --------------Solutions------------- You need to use view's layer to set border property. e.g: #import

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.110 (s). 11 q(s)