by ashish » Tue Jun 02, 2009 8:59 am
Thanks dives, but for me it doesn't work...i am placing my source code..
dashboard=(ListView)findViewById(R.id.dashboard);
dashboard.setOnItemClickListener(this);
dashboard.setItemsCanFocus(true);
dashboard.setSelection(0);
dashboard.setDividerHeight(2);
ArrayAdapter<Object> dashboard_adapter = new ArrayAdapter<Object>(this, R.layout.dashboard_item_layout,R.id.dashboard_item_textview,category_info);
dashboard.setAdapter(dashboard_adapter);
ListView layout
_____________________
<?xml version="1.0" encoding="utf-8"?>
<!--
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/maintheme">
<ImageView
android:id="@+id/icon"
android:layout_height="50px" android:layout_width="fill_parent"/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_dashboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_below="@+id/icon" android:text="My Dashboard" android:layout_centerHorizontal="true" android:textSize="20px" android:textColor="@color/dark_black"/>
<ListView android:id="@+id/dashboard"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000" android:drawingCacheQuality="high" android:smoothScrollbar="true" android:layout_marginBottom="20px" android:layout_marginTop="100px" android:clickable="true" android:focusable="true"/>
</RelativeLayout>
ListView Item Layout
____________________________
<?xml version="1.0" encoding="utf-8"?>
<!--
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dashboard_item_textview"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:minHeight="?android:attr/listPreferredItemHeight" android:text="hello" android:layout_height="40px" android:textColor="@color/dark_black" android:layout_marginRight="50px"/>
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/plus" android:layout_centerHorizontal="true" android:layout_alignParentRight="true" android:id="@+id/edit_category" android:focusable="true" android:clickable="true"></ImageButton>
</RelativeLayout>
I am using ImageButton with my listview item.
and one thing more how to handle click event of button because i am getting a NULL pointer exception.
Thank You.