PDA

View Full Version : CustomView not get focus event



krish.chauhan
10-12-2009, 02:14 AM
Hi ,

I am the new one to the android platform and getting difficulty in getting focus change event on the custom view.

Here is the brief , what i am trying to do.

I am getting some data from http server say students. From that data i am populating my student models. Now i am trying to put these student in a list. For this i am using ListActivity and setting list view. Follwoing is my layout which i am setting a setContentView on listactivity.


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:focusable="true"

android:descendantFocusability="beforeDescendants">


<ListView android:id="@+id/android:list"

android:layout_width="fill_parent"

android:layout_height="fill_parent" android:focusable="true" android:descendantFocusability="beforeDescendants"/>




</RelativeLayout>


I have written my custom view which renders the student infromation as required and using adapter( cutom) i am setting the adaptor to the listview



ArrayList<Strudent> studentList = new ArrayList<Student>();
Vector<Student> students=PersistanceHandler.students;
int size=students.size();
for (int i = 0; i < size; i++) {
studentList .add(students.elementAt(i));
}
StudentAdapter inbox = new StudentAdapter( this, studentList );
setListAdapter( inbox );

Following are the issues i am facing.

1: Custom view are not redered properly. I am using backgroud image ( diffrent for focused and non focused items), but it is rendering only one type of image.
2: i want that on focus, hight of the custom view should change ( on focus i want to show some some data in the bottom), which is not happining.
3: My custom view is never getting the onfocuschanged event..

Any help will be highly appreciated..

Thanks in advance.